remote temperature/...
 
Notifications
Clear all

remote temperature/humidity sensor logging

23 Posts
4 Users
4 Likes
1,795 Views
frogandtoad
(@frogandtoad)
Member
Joined: 5 years ago
Posts: 1458
 
Posted by: @jfabernathy
Posted by: @frogandtoad

Ok, fair enough... I see what you meant now.

By the way, I think an ESP32 of any kind is overkill for intermittent sensing 😉

If I was getting paid to build this, I'd get fired by the costing team.  But when the shipping cost more than the MCU boards, who cares. 😆 

Haha, for sure!

Anyway, it's not a bad idea to go with something "lesser", just to get you through the experience you'll gain from it - You can always use the ESP32 later in a simple swap out.


   
ReplyQuote
(@jfabernathy)
Member
Joined: 3 years ago
Posts: 141
Topic starter  

So I finished this project for now. It was a good learning experience with stuff I have never used before. Here's what is part of the solution for remote monitoring of temperature and humidity with a central recording and displaying station.

Central Station is s Raspberry Pi 4 4GB with USB SATA 1 TB SSD

1st remote is a RPi 3B+ with an Adafruit AHT20 Temperature & Humidity sensor

2nd remote is an Adafruit Metro ESP32-S2 with an Adafruit AHT20

The hardware was picked because I had it for other projects and they got drafted into the job. While both remotes are overkill in the hardware for the job department, the ESP32-S2 is low-power enough to run on battery for a long time without recharging in the application.

The software for the central station was taken from https://sensorsiot.github.io/IOTstack/Getting-Started/   which is a system built with 3 major components use in this type of data gather task: NodeRed for routing the data from sensor to database and setting up graphically. Mosquitto MQTT Broker for routing MQTT messages between subscribers and publishers, Influxdb for storing the reading with timestamps by location, and Grafana for charting and displaying the data.

All of these packages are running as Docker containers with all data stored externally to the containers for easy backup and restore.  This part of the project was really the simplest because it was well documented and exactly what I wanted.

The 1st sensor computer had Raspberry Pi OS Lite with a simple python3 program to read the AHT20 and format a JSON style message containing the readings data in the format that Influxdb uses for import of values and tags.  Since the RPi OS has available libraries for MQTT, I used that to put the readings data out. It cycles on a once per minute basis.

The 2nd sensor was a little bit more complication because the Metro ESP32-S2 is a new board and the CIrcuitpython libraries and Arduino IDE BSP is in development.  Since MQTT libraries don't exist yet for this board, I use http post as a way into the central station. I could not find a way to make the code loop on a 1 minute basis without crashing. It seemed to be good for only one pass.

The turned out to be okay since I wanted the Metro board to deep sleep which wakes up on an alarm and proceeds as if it's the first time every time. I just had to play with the WiFi code to make sure it initialized right coming out of cold boot. There maybe a better way when the libraries are complete.

The central station uses NodeRed to define the information flow. It receives the MQTT data from remote sensor 1 and routes it to the InfluxDB as an array of objects; 1st object is the temperature and humidity readings and the second object is the Location of the reading.

I also use an HTTP in POST node to get the data from the 2nd sensor, parse the json string into objects, and send them on to InfluxDB the same as sensor 1.

The NodeRed flow is a json stream and I've exported to a file attached:

InfluxDB was very simple to get working.  You just create the database, set the user, password, and permissions right and NodeRed just adds the data.  The measurements and tags are defined as they are imported.

Grafana takes InfluxDB as a standard data source and you just link the two with user, password, and database name.

So that's it.  Just 3 long days, lots of googling, Discord texting and forum usage. A few stiff drinks of Bourbon didn't hurt. 😀 

Let me know if anyone would like more information on this project.

If your code won't compile, have another glass of bourbon. Eventual the problem will be solved.


   
ReplyQuote
noweare
(@noweare)
Member
Joined: 4 years ago
Posts: 119
 

Great job, that would of taken me 3 long weeks. That's a lot of different pieces to get working. I would like to do the same thing at some point but I have a long list of projects to get done. I am sure your background was very helpful getting through the material.

~Joe


   
jfabernathy reacted
ReplyQuote
(@jfabernathy)
Member
Joined: 3 years ago
Posts: 141
Topic starter  

@noweare Thanks, but I don't know much about how I did it so fast. Since I retired in 2013 I've been traveling the USA in an RV most of the year. We been checking out National Parks, local breweries and restaurants, etc. No technology except email and text.  But with the Covid lock-down this year we are stuck at home.  I'm glad at least I can learn new things.

I had to learn how to program the new way because my IBM 026 Keypunch machine is broken 😆 

If your code won't compile, have another glass of bourbon. Eventual the problem will be solved.


   
huckOhio reacted
ReplyQuote
frogandtoad
(@frogandtoad)
Member
Joined: 5 years ago
Posts: 1458
 

@jfabernathy

Well done!
Now we know who to ask when we get stuck using those tools 🙂


   
ReplyQuote
(@jfabernathy)
Member
Joined: 3 years ago
Posts: 141
Topic starter  
Posted by: @frogandtoad

@jfabernathy

Well done!
Now we know who to ask when we get stuck using those tools 🙂

Well people can ask me, but I'll just ask Google like I did this time 😀  I might have stayed in computer engineering in 1986 if they'd had Google. Instead I went into technical sales where I just had to know more than the guy I was selling to.

If your code won't compile, have another glass of bourbon. Eventual the problem will be solved.


   
ReplyQuote
noweare
(@noweare)
Member
Joined: 4 years ago
Posts: 119
 

Retirement can be hard to get used to. Good thing you can get into projects like this one. It's good to have a hobby that keeps the mind engaged.


   
frogandtoad reacted
ReplyQuote
(@jfabernathy)
Member
Joined: 3 years ago
Posts: 141
Topic starter  

For anyone reading the code  with a detailed eye, please note that in the Raspberry Pi python3 program there is a potential problem if you try to run multiple RPi's.  In the statement:

ourClient = mqtt.Client() # Create a MQTT client object

I had used a literal constant in quotes as an identifier which is supposed to be unique.  I removed it and now the system automatically generates a random identifier so multiple Raspberry Pis can be used sending data to the same MQTT Broker.

 

If your code won't compile, have another glass of bourbon. Eventual the problem will be solved.


   
ReplyQuote
Page 2 / 2