Sending temperature data to....somwhere
Sending temperature data to....somwhere
Hi, thanks to the help of this forum i flashed MicroPython v1.9.1-8 on my ESP2866. The board is connected to my Wifi.
I succesfully conected a DHT22, written a script (http://docs.micropython.org/en/latest/e ... dht-driver) and got my temperature as an output.
My problem now ist.... how to send it somewhere via wifi?
And where to send it best? I would like to collect the temperature data every 5 Minutes. And best case display it in some graph. it could be send to a txt-file on a RPi in the Network or something that is suited for later use in a graph. I don't know.
Help would be appreciated.
Greetings, Tom
I succesfully conected a DHT22, written a script (http://docs.micropython.org/en/latest/e ... dht-driver) and got my temperature as an output.
My problem now ist.... how to send it somewhere via wifi?
And where to send it best? I would like to collect the temperature data every 5 Minutes. And best case display it in some graph. it could be send to a txt-file on a RPi in the Network or something that is suited for later use in a graph. I don't know.
Help would be appreciated.
Greetings, Tom
-
- Posts: 969
- Joined: Sat Feb 03, 2018 7:02 pm
Re: Sending temperature data to....somwhere
I'll make it easy for you: use mqtt and check https://www.home-assistant.io/.
But for how to use mqtt on your esp8266 you actually have to use google or the forum search and read about it yourself
But for how to use mqtt on your esp8266 you actually have to use google or the forum search and read about it yourself
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
Re: Sending temperature data to....somwhere
Thanks that is very helpful.kevinkk525 wrote: ↑Wed Nov 21, 2018 9:19 amI'll make it easy for you: use mqtt and check https://www.home-assistant.io/
I didn't expect anyone to do that. It's just hard to look for something, if you don't know what to look for.kevinkk525 wrote: ↑Wed Nov 21, 2018 9:19 amBut for how to use mqtt on your esp8266 you actually have to use google or the forum search and read about it yourself
Thanks for the help. I'll figure out what mqtt is and how to use it.
Greetings, Tom
-
- Posts: 969
- Joined: Sat Feb 03, 2018 7:02 pm
Re: Sending temperature data to....somwhere
Good luck! Setting up home-assistant can be a demanding process but in the end it's worth it.
mqtt client on the esp8266 is quite easy. Depending on your level of knowledge of python there are different options for mqtt. You could even use my framework https://github.com/kevinkk525/pysmartnode that takes care of everything and just implement your script into that but if you are new to programming in general or don't know how to build a custom firmware or what uasyncio is, it might be better to start small and use the umqtt library https://github.com/micropython/micropyt ... qtt.simple for esp8266 and start working with it.
mqtt client on the esp8266 is quite easy. Depending on your level of knowledge of python there are different options for mqtt. You could even use my framework https://github.com/kevinkk525/pysmartnode that takes care of everything and just implement your script into that but if you are new to programming in general or don't know how to build a custom firmware or what uasyncio is, it might be better to start small and use the umqtt library https://github.com/micropython/micropyt ... qtt.simple for esp8266 and start working with it.
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
- Mike Teachman
- Posts: 155
- Joined: Mon Jun 13, 2016 3:19 pm
- Location: Victoria, BC, Canada
Re: Sending temperature data to....somwhere
You might take a look at the tutorials and code examples I put together describing how to use Thingspeak and Adafruit IO with MQTT. Examples for publish and subscribe.
Thingspeak
https://github.com/MikeTeachman/micropy ... tt-esp8266
and
Adafruit IO
https://github.com/MikeTeachman/micropy ... tt-esp8266
The examples use the free heap statistics to illustrate the concepts. To publish temperature data change the following line in the example uPy publish code
Substitute your reading in place of the heap statistic. And, likely change the variable name throughout to better match your temperature application.
good luck!
Thingspeak
https://github.com/MikeTeachman/micropy ... tt-esp8266
and
Adafruit IO
https://github.com/MikeTeachman/micropy ... tt-esp8266
The examples use the free heap statistics to illustrate the concepts. To publish temperature data change the following line in the example uPy publish code
Code: Select all
free_heap_in_bytes = gc.mem_free()
good luck!
Re: Sending temperature data to....somwhere
Hi Mike,
This is great stuff thanks for posting.
I am new to this networking using MQTT so this is a really basic question. When connecting as a subscriber to the Adafruit IO dashboard how would I send a command to turn off an LED for example?
On my Adafruit Feather Huzzah I can toggle the LED using led.ON or led.OFF. How can this command be sent from the dashboard?
Best regards,
Chris
This is great stuff thanks for posting.
I am new to this networking using MQTT so this is a really basic question. When connecting as a subscriber to the Adafruit IO dashboard how would I send a command to turn off an LED for example?
On my Adafruit Feather Huzzah I can toggle the LED using led.ON or led.OFF. How can this command be sent from the dashboard?
Best regards,
Chris
- Mike Teachman
- Posts: 155
- Joined: Mon Jun 13, 2016 3:19 pm
- Location: Victoria, BC, Canada
Re: Sending temperature data to....somwhere
Hi Chris,
That's totally doable. Go to the Adafruit IO home, then create a new Feed, called say "switch". Then, open a Dashboard, create a new Toggle block and associate that block to the feed "switch". Next, in MicroPython, subscribe to the feed "switch". MQTT will update value of that feed each time the Toggle block on the dashboard changes value. You can use the value of the feed to control the LED.
It's possible to bring in an analog value as well, using the Slider block. Or, the Text block can bring in dashboard text via MQTT. I haven't tried out the Momentary push button.
Hope that works ... Mike
That's totally doable. Go to the Adafruit IO home, then create a new Feed, called say "switch". Then, open a Dashboard, create a new Toggle block and associate that block to the feed "switch". Next, in MicroPython, subscribe to the feed "switch". MQTT will update value of that feed each time the Toggle block on the dashboard changes value. You can use the value of the feed to control the LED.
It's possible to bring in an analog value as well, using the Slider block. Or, the Text block can bring in dashboard text via MQTT. I haven't tried out the Momentary push button.
Hope that works ... Mike