-
-
hey mr @davidhay. I am trying your code out and I have replaced the host and wifi info with my own, but for some odd reason i am getting a code-6 message not found
-
-
I want it to periodically send data to my server... I feel so lost... Okay, so I am running an express server on my computer localhost:3000... I cant figure out how to fetch the data off the esp8266 or like you said, have the esp8266 send the data to my server... I know it is probably so simple to do but I cant put 2 and 2 together for some reason.. I was using a third party library Axios to try to make a call to the esp but can't get that to work. .. Am I on the right path at least? Thanks
-
const wifi = require("Wifi"); const ssid = ""; const password = ""; wifi.connect(ssid, {password:password}, function(e) { if (e) { console.log('error during connect:',e); wifi.disconnect(); } else { console.log('connected to',ssid); require("Wifi").getIP((err, ipinfo) => {console.log(ipinfo)}); wifi.stopAP(); //wifi.save(); } }); const sensor = require("HC-SR04").connect(NodeMCU.D1,NodeMCU.D2,function(dist) { const inches = dist * 0.393701; n = inches.toFixed(2); console.log(n); setInterval(function() { sensor.trigger(); // send pulse }, 10000); function postMe() { content = "Hello"; var options = { host: 'whatdoIputhereifIamrunningalocalserverwithexpress', port: '80', path:'/', method:'POST', headers: { "Content-Type":"application/json", "Content-Length":content.length } }; require("http").request(options, function(res) { // ... }).end(content); }
This is pretty much as far As I've gotten with my code.. I tried to do a test post with no luck so far
-
Aww okay, yes so i would want it to periodically send data to my server... I feel so lost... Okay, so I am running an express server on my computer localhost:3000... I cant figure out how to fetch the data off the esp8266 or like you said, have the esp8266 send the data to my server... I know it is probably so simple to do but I cant put 2 and 2 together for some reason.. I was using a third party library Axios to try to make a call to the esp but can't get that to work. .. Am I on the right path at least? Thanks
-
-
So currently I am in a full stack webdev bootcamp and I need to make a project using the mern stack, mongodb, express, react, nodejs.. I just need guidance on how to structure my esp2866.. I have my sensor hooked up already and its running, but for the life of me, I can't figure out how to send that data to my client side. Any info would be amazing! Thanks all
Thanks @AkosLukacs