User Tools

Site Tools


user:jan001:intro_iot_tasmota_nig

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
user:jan001:intro_iot_tasmota_nig [2021/10/11 11:45] jan001user:jan001:intro_iot_tasmota_nig [2023/03/28 15:21] (current) – [Doing stuff] rolf.becker
Line 64: Line 64:
 Allons-y! Allons-y!
  
 +==== DS18B20 Pinout ====
 +
 +  * Cable VErsion: red -> 3.3V , blue -> GND , yellow -> data (1wire protocol)
 +  * Breakout board version: "+" -> 3.3V , "-" -> GND, out -> data 
 ==== Breadboard prepartion ==== ==== Breadboard prepartion ====
 So get all your stuff together and build up the breadboard. Here is the schematic. If your Programmer has male headers, you can plug it directly into the breadboard. {{ :user:jan001:intro-iot_bb.png?600 |}} So get all your stuff together and build up the breadboard. Here is the schematic. If your Programmer has male headers, you can plug it directly into the breadboard. {{ :user:jan001:intro-iot_bb.png?600 |}}
 +
 +<WRAP center round alert 60%>
 +\\
 +The data line of the 1Wire bus (blue) \\ is not connected correctly in the diagram above! 
 +</WRAP>
  
 ==== Installing the Tasmotizer ==== ==== Installing the Tasmotizer ====
Line 132: Line 141:
 ''%%Rule1 ON Time#Minute|5 DO backlog publish %prefix%/%topic%/SENSOR %value% ENDON%%'' ''%%Rule1 ON Time#Minute|5 DO backlog publish %prefix%/%topic%/SENSOR %value% ENDON%%''
  
-I will not go into detail here. This is just for reference. If you really want to know how to utilize rules read the documentation linked above. +I will not go into detail here. This is just for reference. If you really want to know how to utilize rules read the documentation linked above. 
 + 
 +The only thing we now need from Tasmota is the topic, on which the sensor data get published. The easiest way to do this is to watch the console. First, open up the console. Somewhere should be a line which includes: ''%%MQT: tele/tasmota_1A4332/SENSOR%%''. All lines with ''%%MQT%%'' state that something is happening with MQTT. The rest after the ''%%MQT%%'' is the MQTT topic. This will be different on every Tasmota instance. At least the part in the middle, because this is a randomly generated name for your specific ESP. I found the line in my console and it looks like this: 
 + 
 +''%%10:51:01.412 MQT: tele/tasmota_1A4332/SENSOR = {"Time":"2021-10-11T10:51:01","DS18B20":{"Id":"0000075EDD2C","Temperature":21.8},"TempUnit":"C"}%%'' 
 + 
 +The part after the equal is the message. It includes a timestamp and the sensor data. 
 + 
 +==== Making a graph ==== 
 + 
 +I hope yall have read the article and followed the steps for setting up your NIG. You are going to need it. 
 + 
 +=== Node-Red === 
 +So in Node-Red, we have to start with an ''%%mqtt in%%'' node. If we open up the menu of that node, we first have to add a server. Click on the little pen icon next to the server field for that. We can then use the same server/host and port settings as before. Click ''%%Save%%'' to continue. Then we need to define the topic we want to subscribe to. For this, we just need to copy the topic from the Tasmota console, where we found it before. Something like this: ''%%tele/tasmota_1A3FCC/SENSOR%%''. We can leave the ''%%QoS%%'' (Quality of Sevice) at default. **Important** Set ''%%Output%%'' to ''%%a parsed JSON object%%''. Click ''%%Done%%''. Now we need to extract the temperature from the message. The message will be formatted as a [[https://www.w3schools.com/whatis/whatis_json.asp|JSON]]-Object, which can hold values in key-value pairs. This can be easily extracted with two lines of javascript. So drag in a function node. Copy in these two lines of javascript:  
 +<code> 
 +let temperature = msg.payload.DS18B20.Temperature; 
 +return { payload: temperature }; 
 +</code> 
 +First we create a value ''%%temperature%%''. The messages between all the nodes in Node-Red have the raw values in a key called ''%%payload%%''. So we access the message with ''%%msg%%'' then in this JSON object we access the object called ''%%payload%%''. This has the message in it we found earlier in the console. So we can access the object ''%%DS18B20%%'' and last the key ''%%Temperature%%'' to get the sensor value. We then pack everything in our own little message object with just the raw number value as a payload. This will be returned, so send to the next node. 
 +The last node we need is the ''%%influxdb out%%''-node. Attach this to the output of the function node. Here you just need to select your influxdb and give the measurement a name that is easily distinguishable. I choose ''%%lab_temperature%%''. You can now deploy your flow by selecting ''%%Deploy%%''. Your flow should look something like this: 
 + 
 +{{ :user:jan001:screenshot_from_2021-10-11_12-48-19.png?600 |}}
  
 +=== Grafana ===
 +We are nearly finished! Let's open up Grafana. Start with creating a new dashboard by hovering over "plus"-icon on the left side of the screen and select ''%%Dashboard%%''. Add a new panel. In the query-part select under ''%%FROM -> select measurement%%'' the value name you gave the measurement in Node-Red. Under ''%%SELECT%%'' remove ''%%mean()%%'' and put in ''%%distinct%%'', so you get a nice line graph. We can now do some more advanced stuff. We know that the lab temperature will always be in a range from 0 to 40 degrees. When we open up the tab ''%%Axes%%'' on the right side, we can set for ''%%Left Y%%'' (so the left Y-axis) the ''%%Y-Min%%'' to 0 and the ''%%Y-Max%%'' to 40. You can also change the name of the graph under ''%%Settings%%''-tab. Click ''%%Save%%'' and ''%%Apply%%'' if you are finished and that's it. Look at your nice little graph!
  
 +{{ :user:jan001:screenshot_from_2021-10-11_13-26-49.png?600 | Graph}}
  
 +I hope you learned something today! 
  
 ===== References ===== ===== References =====
Line 142: Line 176:
   - [[https://github.com/tasmota/tasmotizer|Tasmotizer - Jacek Ziółkowski - 2019]]   - [[https://github.com/tasmota/tasmotizer|Tasmotizer - Jacek Ziółkowski - 2019]]
   - [[https://tasmota.github.io/docs/|Tasmota Community]]   - [[https://tasmota.github.io/docs/|Tasmota Community]]
 +  - [[https://www.sensatio.io/sensors/dallas-ds18b20|Dallas DS18B20]]
user/jan001/intro_iot_tasmota_nig.1633945521.txt.gz · Last modified: 2021/10/11 11:45 by jan001