Changes

m
Fix the break lines of the article
Line 9: Line 9:     
This article will provide a step-by-step configuration on how to configure data to server using a custom script that allows 1-wire data to be sent on an HTTP server.  
 
This article will provide a step-by-step configuration on how to configure data to server using a custom script that allows 1-wire data to be sent on an HTTP server.  
      
For the instruction on how to setup 1-Wire sensor with the TRB141 kindly navigate to this [[TRB141 1-Wire Setup/Configuration|article]] that we have.
 
For the instruction on how to setup 1-Wire sensor with the TRB141 kindly navigate to this [[TRB141 1-Wire Setup/Configuration|article]] that we have.
Line 74: Line 73:     
[[File:Networking trb user scripts examples cli 1wire data to server script.png.png|border|left]]
 
[[File:Networking trb user scripts examples cli 1wire data to server script.png.png|border|left]]
 +
 +
 +
      Line 105: Line 107:  
This line uses '''‘ubus’''' command to call the '''‘ioman.gpio.onewire’''' service and execute the '''‘status’''' command. The output of this command is saved to the ''status'' variable.
 
This line uses '''‘ubus’''' command to call the '''‘ioman.gpio.onewire’''' service and execute the '''‘status’''' command. The output of this command is saved to the ''status'' variable.
 
[[File:Networking trb user scripts cli code explanation1.png|left]]
 
[[File:Networking trb user scripts cli code explanation1.png|left]]
 +
 +
 +
      Line 115: Line 120:  
After that, it checks if the value stored in the '''‘value’''' variable is equal to 0. If it is, the '''‘ubus’''' command is used to call the '''‘ioman.gpio.onewire’''' service and execute the ‘update’ command, which updates the ‘value’ parameter to 1.
 
After that, it checks if the value stored in the '''‘value’''' variable is equal to 0. If it is, the '''‘ubus’''' command is used to call the '''‘ioman.gpio.onewire’''' service and execute the ‘update’ command, which updates the ‘value’ parameter to 1.
 
[[File:Networking trb user scripts cli code explanation2.png|left]]
 
[[File:Networking trb user scripts cli code explanation2.png|left]]
 +
 +
 +
      Line 134: Line 142:  
After that, it extracts the sensor ID from the sensor directory path using the ‘basename’ command and stores it in the ‘sensor_id’ variable.
 
After that, it extracts the sensor ID from the sensor directory path using the ‘basename’ command and stores it in the ‘sensor_id’ variable.
 
[[File:Networking trb user scripts cli code explanation4.png|left]]
 
[[File:Networking trb user scripts cli code explanation4.png|left]]
 +
      Line 144: Line 153:  
Which then converts the raw temperature value to degrees Celsius by dividing it by 1000 and then formatting it with two decimal places using '''‘printf’'''. The resulting temperature value is stored in the '''‘temp’''' variable.
 
Which then converts the raw temperature value to degrees Celsius by dividing it by 1000 and then formatting it with two decimal places using '''‘printf’'''. The resulting temperature value is stored in the '''‘temp’''' variable.
 
[[File:Networking trb user scripts cli code explanation5.png|left]]
 
[[File:Networking trb user scripts cli code explanation5.png|left]]
        Line 152: Line 160:  
These lines define the URL of the server to which the temperature data will be sent and the payload data that will be sent with each request. The payload includes the '''‘sensor_id’''' and '''‘temp’''' variables, formatted as a JSON object.
 
These lines define the URL of the server to which the temperature data will be sent and the payload data that will be sent with each request. The payload includes the '''‘sensor_id’''' and '''‘temp’''' variables, formatted as a JSON object.
 
[[File:Networking trb user scripts cli code explanation6.png|left]]
 
[[File:Networking trb user scripts cli code explanation6.png|left]]
        Line 160: Line 167:  
This line uses the '''‘curl’''' command to send an HTTP POST request to the server specified by '''‘$SERVER_URL’'''. The '''‘-X POST’''' option specifies that the request should be a POST request, and the '''‘-H “Content-Type: application/json”’''' option specifies that the payload data is in JSON format. The '''‘-d “$PAYLOAD”’''' option specifies the payload data to be sent with the request.
 
This line uses the '''‘curl’''' command to send an HTTP POST request to the server specified by '''‘$SERVER_URL’'''. The '''‘-X POST’''' option specifies that the request should be a POST request, and the '''‘-H “Content-Type: application/json”’''' option specifies that the payload data is in JSON format. The '''‘-d “$PAYLOAD”’''' option specifies the payload data to be sent with the request.
 
[[File:Networking trb user scripts cli code explanation7.png|left]]
 
[[File:Networking trb user scripts cli code explanation7.png|left]]
 +
      Line 166: Line 174:  
=== Output ===
 
=== Output ===
 
[[File:Networking trb user scripts HTTP listener screenshot.png|left|800x800px]]
 
[[File:Networking trb user scripts HTTP listener screenshot.png|left|800x800px]]
       

Navigation menu