Temperature is one of the most commonly measured physical quantities, yet different parts of the world use different scales. The United States uses Fahrenheit while most other countries use Celsius. This project helps you monitor temperature in both scales simultaneously using the Bolt IoT WiFi module and an LM35 temperature sensor.
Using the Bolt Cloud platform, you can visualize real-time temperature readings in both Fahrenheit and Celsius on a web dashboard, making it easy to understand and compare the two scales.
| Component | Quantity |
|---|---|
| Bolt WiFi Module | 1 |
| LM35 Temperature Sensor | 1 |
| Breadboard | 1 |
| Jumper Wires | 3 |
The LM35 is a precision temperature sensor that outputs an analog voltage proportional to the temperature. It outputs 10mV per degree Celsius, making it simple to convert the analog reading to a temperature value. The sensor has three pins: VCC, Output, and GND.
Place the LM35 on the breadboard and connect it to the Bolt WiFi module as follows:
| LM35 Pin | Bolt WiFi Module |
|---|---|
| VCC (Left pin, flat side facing you) | 5V |
| Output (Middle pin) | A0 (Analog Input) |
| GND (Right pin) | GND |
Make sure the flat side of the LM35 is facing you when identifying the pins from left to right.
Connect the Bolt WiFi module to a power source using a micro-USB cable. Ensure the module connects to your WiFi network and appears online in the Bolt Cloud dashboard.
Log in to cloud.boltiot.com. Create a new product with the type set to "Input" and interface type as "GPIO". Link your Bolt device to this product.
Click on the Configure icon and add the following JavaScript code to the product code section. This code reads the analog value from the LM35 sensor, converts it to both Celsius and Fahrenheit, and displays both values:
setChartLibrary('google-chart');
setChartTitle('Temperature Monitor');
setChartType('lineGraph');
setAxisName('Time', 'Temperature');
setCrosshair(true);
mul(100/1024);
plotChart('time_stamp', 'temp_celsius', 'Celsius');
// Fahrenheit conversion: F = (C * 9/5) + 32
var celsius = data.temp_celsius;
var fahrenheit = (celsius * 9/5) + 32;
For a more comprehensive solution, you can use the Bolt Python library to read the sensor data and display both temperature scales. Create a file called temp_monitor.py:
import json
from boltiot import Bolt
from time import sleep
API_KEY = "YOUR_API_KEY"
DEVICE_ID = "YOUR_DEVICE_ID"
mybolt = Bolt(API_KEY, DEVICE_ID)
while True:
response = mybolt.analogRead("A0")
data = json.loads(response)
if data["success"] == 1:
sensor_value = int(data["value"])
voltage = sensor_value * (5.0 / 1024.0)
celsius = voltage * 100
fahrenheit = (celsius * 9.0/5.0) + 32.0
print("Sensor Value: " + str(sensor_value))
print("Temperature: {:.2f} C / {:.2f} F".format(celsius, fahrenheit))
print("---")
else:
print("Error reading sensor: " + str(data))
sleep(5)
Replace YOUR_API_KEY and YOUR_DEVICE_ID with your actual Bolt Cloud credentials. Run the script to see temperature readings printed in both Celsius and Fahrenheit every 5 seconds.
The LM35 sensor outputs 10mV per degree Celsius. The Bolt WiFi module's analog-to-digital converter (ADC) has a 10-bit resolution, meaning it maps 0-5V to values 0-1024.
The conversion formula is:
For example, if the sensor reads a value of 62: voltage = 0.303V, Celsius = 30.3, Fahrenheit = 86.5.
With this simple project, you can monitor temperature in both Fahrenheit and Celsius simultaneously from anywhere in the world. The Bolt Cloud provides real-time data visualization, and the Python API allows you to build more advanced applications on top of the temperature data.
Want to build more such IoT and ML projects? Want to learn IoT and ML from basics? Check out the Bolt IoT and ML training. This online video training is excellent for those who want to start with IoT and ML because it teaches you to build projects from the basics.
Get the latest IoT tutorials, projects, and updates delivered to your inbox.