{"id":1678,"date":"2023-01-21T18:37:48","date_gmt":"2023-01-22T02:37:48","guid":{"rendered":"https:\/\/xyzcreativeworks.com\/?p=1678"},"modified":"2023-01-21T18:38:35","modified_gmt":"2023-01-22T02:38:35","slug":"build-a-cloud-raspberry-pi-pico-w-temperature-humidity-logger","status":"publish","type":"post","link":"https:\/\/xyzcreativeworks.com\/build-a-cloud-raspberry-pi-pico-w-temperature-humidity-logger\/","title":{"rendered":"Build a cloud Raspberry Pi Pico W temperature\/humidity logger"},"content":{"rendered":"\n
I live in a pretty humid part of the world and that has left me worried for some of my valuables.<\/p>\n\n\n\n
If you live in a place with high humidity, your camera lenses, inflatable watercraft and leather shoes can break down much faster.<\/p>\n\n\n\n
I have designated a cabinet as a “low-humidity zone”, in an air-conditioned room and desiccant pellets within this cabinet.<\/p>\n\n\n\n
I found myself needing something that could tell me the temperature and humidity of the cabinet. Plus, I wanted to connect it online for temperature logging purposes.<\/p>\n\n\n\n
Here’s how to build something like this.<\/p>\n\n\n
I used a DHT22 but you can use a DHT11 or a BME280, 680, 688 board. The code below uses a DHT22, so you will have to modify the code if you use something else.<\/p>\n\n\n
Flashing your Pico W<\/a><\/p>\n\n\n\n Uploading files to Pico W<\/a><\/p>\n\n\n\n I generally prefer to build a basic device before I start connecting it online.<\/p>\n\n\n\n First up, let’s connect the components up.<\/p>\n\n\n\n The diagram is a bit complicated, so here’s how you can connect everything.<\/p>\n\n\n With the DHT22 facing you, the pins are, from left to right:<\/p>\n\n\n\n VCC, DATA, null pin, GND<\/p>\n\n\n\n You will need the TM1637 library<\/a>. Here’s how to use it:<\/p>\n\n\nLet’s build a basic temperature\/humidity reader<\/h2>\n\n\n
3V3\/GND connections<\/h3>\n\n\n
Pin on Pico W<\/td> Destination<\/td><\/tr> 3.3V<\/td> VCC on display and DHT22<\/td><\/tr> GND<\/td> GND on both devices<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n DHT22 connections<\/h3>\n\n\n
Pin on Pico W<\/td> Destination<\/td><\/tr> GPIO10<\/td> DHT22 DATA with 10K resistor in between<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n LED display with TM1637<\/h3>\n\n\n
Pin on Pico W<\/td> Destination<\/td><\/tr> GPIO16<\/td> CLK<\/td><\/tr> GPIO17<\/td> DIO<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n Coding the Pico W temp\/humidity logger<\/h2>\n\n\n
import tm1637\nfrom machine import Pin\nimport dht\nimport time\n\ntm = tm1637.TM1637(clk=Pin(16), dio=Pin(17))\n\ndht22 = dht.DHT22(Pin(10))\n\nwhile True:\n try:\n dht22.measure()\n print(f\"temp:{dht22.temperature()}, humidity:{dht22.humidity()}\")\n tm.numbers(int(dht22.temperature()), int(dht22.humidity()), colon=True)\n time.sleep(2)\n \n except:\n tm.show('errr')<\/code><\/pre>\n\n\n\n