node-red: [Error Msg] Gathering GPS Data
Dear volunteers
I’m writing to show my small errors of Node-RED to figure out. I made a GPS simulator at home. This simulator automatically generates a single JSON data every 5 sec.
myData = {'d':-33.87} # a single latitude
and then the GPS simulator sends the JSON data from a rapspberry pi to IBM Bluemix. So, my main problem is ‘No Response Object’.
Please help me fix my errors.
(1) GPS Python Simulator
import time
import numpy as np
import ibmiotf.gateway
import math
try:
gatewayOptions = {"org": "myOrg", "type": "iotgateway001", "id": "iotgateway001", "auth-method": "token", "auth-token": "myPassword"}
gatewayCli = ibmiotf.gateway.Client(gatewayOptions)
gatewayCli.connect()
while True:
myData = {'d':-33.87} # a single latitude
gatewayCli.publishDeviceEvent("iotgateway001", "iotgateway001", "iotgateway001", "json", myData, qos=1 )
time.sleep(5)
except ibmiotf.ConnectionException as e:
print(e)
(2) Node-RED

[{"id":"22ec4899.822a98","type":"ibmiot in","z":"fd8b5730.ad96f8","authentication":"boundService","apiKey":"","inputType":"evt","deviceId":"iotgateway001","applicationId":"","deviceType":"iotgateway001","eventType":"iotgateway001","commandType":"","format":"json","name":"iotgateway001","service":"registered","allDevices":"","allApplications":true,"allDeviceTypes":"","allEvents":false,"allCommands":"","allFormats":true,"qos":"2","x":160,"y":600,"wires":[["c96429d9.a0f028"]]},{"id":"419a6d7e.d4eed4","type":"http in","z":"fd8b5730.ad96f8","name":"/gatherFromDevice","url":"/gatherFromDevice","method":"get","swaggerDoc":"","x":210,"y":440,"wires":[["8979c5b8.b05148"]]},{"id":"e48c83fd.418ad","type":"function","z":"fd8b5730.ad96f8","name":"setHTTPheader","func":"// If sending JSON data the content type is:\n//msg.headers={\"Content-Type\":\"application/json\"};\n\n// For HTML use the content type line below:\nmsg.headers={\"Content-Type\":\"text/html\"};\nreturn msg;","outputs":1,"noerr":0,"x":760,"y":440,"wires":[["efa738c.ee327c8"]]},{"id":"8979c5b8.b05148","type":"template","z":"fd8b5730.ad96f8","name":"simple html page","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<h1>What's data? This is a latitude: {{ payload.d }} </h1>\n","x":510,"y":440,"wires":[["ead250eb.79b7d","e48c83fd.418ad"]]},{"id":"c96429d9.a0f028","type":"function","z":"fd8b5730.ad96f8","name":"gatherGpsData","func":"var data = {'d': msg.payload.d};\n\nreturn msg;","outputs":1,"noerr":0,"x":220,"y":500,"wires":[["f3ea8ed5.e54e7","8979c5b8.b05148","2fea4062.70e67"]]},{"id":"ead250eb.79b7d","type":"debug","z":"fd8b5730.ad96f8","name":"","active":true,"console":"false","complete":"false","x":750,"y":500,"wires":[]},{"id":"efa738c.ee327c8","type":"http response","z":"fd8b5730.ad96f8","name":"/gatherFromDevice","x":970,"y":440,"wires":[]},{"id":"2fea4062.70e67","type":"cloudant out","z":"fd8b5730.ad96f8","name":"gpsNoSQLDB","cloudant":"9488e297.3a85a","database":"gpsNoSQLDB","service":"_ext_","payonly":true,"operation":"insert","x":500,"y":499,"wires":[]},{"id":"f3ea8ed5.e54e7","type":"debug","z":"fd8b5730.ad96f8","name":"","active":true,"console":"false","complete":"false","x":430,"y":560,"wires":[]},{"id":"9488e297.3a85a","type":"cloudant","z":"fd8b5730.ad96f8","host":"0bb93e00-1487-45cd-b407-22ef76beb614-bluemix.cloudant.com","name":"gpsNoSQLDB"}]
(3) GPS Data Buffer in NodeRED & Simple HTML Page






I will gather a special data with GPS Location to improve near environment.
http://iotmaker.mybluemix.net/whereIsMyDevice

<!DOCTYPE html>
<html>
<head>
<style>
#map {
height: 400px;
width: 100%;
}
</style>
</head>
<body>
<h2>My IoT Device Location: Latitude: -33.87559993931576 , Longitude: 151.21599197387695 </h2>
<div id="map"></div>
<script>
function initMap() {
var IoTDevice = {lat: -33.87559993931576,lng: 151.21599197387695 };
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 18,
center: IoTDevice
});
var marker = new google.maps.Marker({
position: IoTDevice,
map: map
});
}
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDhA8Lb-e_JvMYmEh2RLA3rFBeEllQYsFI&callback=initMap">
</script>
</body>
</html>
Thank you for giving your precious time.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 25 (10 by maintainers)
You are getting closer… but you are not storing the iotgateway data anywhere that the /gatherFromDevice flow can retrieve it from.
You have to delete the path from the Watson IoT node and the HTTP Response node.
Specifically the link between “GpsDataBuffer” and “simple html page” functions.
Then use the context to pass the data
The HTTP Response node is used to send a response to requests coming from the HTTP In node.
The flow you have coming from WatsonIoT is wired through to the http response node… so when a message arrives from Watson, it gets passed to the response node, but there’s not been an http request at the start of the flow.
If you want the http request to return the latest data you’ve received from Watson, you’ll need to store the data in flow context and retrieve it in the http flow.
Hi,
Please use the node-red mailing list (linked at the bottom of nodered.org) for general support questions; this issue list is for bugs.
Nick
Ma