-
user1 is written to the address for normal flashing user2 is flashed to a different address for flashing over wifi I believe. I've not flashed the latest firmware yet but use the NodeMCU firmware flasher,
boot_v1.6.bin - 0x00000
espruino_esp8266_user1.bin - 0x01000
esp_init_data_default.bin - 0x3FC000
blank.bin - 0x3FE000 -
-
Thanks, I had looked at the examples and have used it previously, clearly I needed to sleep on it but I think I get it now.
I could type:
192.168.0.13/set?23
function onPageRequest(req, res) { var a = url.parse(req.url, true); if (a.pathname=="/set") { targetRoomTemp= a.query }
to change the varible 'targetRoomTemp' to 23?
Or with 192.168.0.13/set/23
function onPageRequest(req, res) { var a = url.parse(req.url, true); 'a.pathname'.split('/')==[1,2,3]; if (a.pathname(2)=="/set") { targetRoomTemp= a.pathname(3); }
-
Hello,
I currently have a pico running my heating through a few 5V relays. It is not quite as simple as a thermostat; It heats a store of water and uses a pump to provide hot water and heating. I would like to be able to connect to the system over wifi, gather the data and adjust variables. I may install home-assistant so I would like to emulate a rest type interface. I am testing the wifi on a ESP8266 at the moment until I buy a shim.
I have played with examples previously with control over wifi, I can turn on a pin and read variables but I don’t understand how to interrogate the url and move the information into a variable. I thought of using an if statement to check if the number is 1 and incrementing to by 1 if it’s not and rechecking but it seems a bit adhoc.
I would like to be able to type something like:
"192.168.0.13/set/room/23"
and have the 23 move to the variable for the target room temperature. I assume I would need to use the parse function? A simple example of how to achieve this would be very much appreciated.
Basic example that I have been using:
// define the function beServer function beServer() { var http = require ("http"); var httpServer = http.createServer(function(request, response) { print(request); //Handle favicon requests if (request.url == "/favicon.ico") { response.writeHead(404); response.end(); return; } // handle requests and serve web page response.write("<html><body>"); if (request.url == "/ledOn"){ response.write("The led is on."); digitalWrite(ledPin, 1); } else if (request.url == "/ledOff"){ response.write("The led is off"); digitalWrite(ledPin, 0); } else { response.write("Sorry... I didn't understand"); } response.end(" "); }); // End of new browser request httpServer.listen(80); print("Now being an HTTP server!"); } // End of beServer
Background information about the actual system:
A thermometer switches the boiler when the store cools below a pre-set limit currently cutting in at 62 and out at 72 deg. A valve lets water from the heating circuit into the cylinder when the flow is above 45 deg and within 10 deg of the cylinder temp and the boiler is running. The water pump starts (and pumps water through a heat exchanger) when a flowmeter picks up a flow higher than 1l/min. so lots for thermometers basically. -
Hello,
Have you considered the stm32f4stamp as a base for a new board? Are you going to keep selling the pico when the new boards go on sale? The micro-usb socket will certainly be an improvement.
-
Gordon,
I have tried your minified code from the other thread and I am receiving and I am getting the following
>get() =169289 >get() =169350 >get() =169282 >get() =169263 >get() =169297
Does this appear reasonable? the load cell is currently laying on the table.
I can get a reading using digitalPulse but it is much larger at around 338642 and differs by a few hundred between readings.
Many thanks again...
-
Hi,
I stumbled upon THIS webpage for the electric imp.
Github link to the code
It has implemented the read function using :function read_weight(){ //This is bit banged so we //bind calls to local variables //to speed things up. //Takes about 2.2mS to do the read local sw = spi.write.bindenv(spi); local dr = data.read.bindenv(data); local val = 0; for(local i = 24; i >= 0; i--){ sw(PULSE); val += dr() ? math.pow(2, i) : 0; } return (val-ZERO_OFFSET)/GAIN; //Value in grams }
It does point out that I should have typed >0 in the for statement not 1...
I will test my code again with the refinements suggested by Gordon later tonight hopefully and will report back.Many thanks,
Aaron
-
Hello,
I am trying to get the HX711 IC to work with espruino. I have had some issues with getting it to work and would be very grateful if someone could advise me. The datasheet can be found at
https://cdn.sparkfun.com/datasheets/Sensors/ForceFlex/hx711_english.pdfMy code so far:
// Strain Gauge Program for HX711 // By: Aaron Button // Date: 16/05/16 //______________________________________________________ // //User settable variables //______________________________________________________ // //Set Gain 1= 128, 2=32, 3=64. var gain = 1; //Calibration factor var calFac = -100; // Pin Number for strain gauge SCK var sgSend = C12; // Pin Number for strain gauge DOUT var sgRecieve = C10; // //Calculated Variables //______________________________________________________ // var strain = 0; var weight = 0; var bitValue = 0; var tareStrain = 0; // //Strain Gauge // //Define the function for the strain gauge function strainGauge(){ print("running strainGauge Routine"); //Check if the HX711 Controller is ready to transmit if (digitalRead(sgRecieve) === 0){ //Run the following code 24 times print("sgRecieve = 0"); for (var i=24; i>1;i--){ print("loop"); print(i); digitalPulse(sgSend,1,0.001);//pulse on for 1us if (digitalRead(sgRecieve) == 1)//check if HX711 output if logic 1 { bitValue = Math.pow(2, i);//calculate bit value print("bitValue =" + bitValue); strain = strain + bitValue;//add the value to the total print("strain =" + strain); } // set the gain for the next transmission for (var o=0; o<gain;o++)//repeat the code as defined by gain { digitalPulse(sgSend,1,0.001);//pulse on for 1us }// End of gain statement weight = (strain*calFac); print("weight =" + weight); } // End for statement } // End if ready to transmit function }// End Function strainGauge // Set the unladen strain to 0 function tare(){ tareStrain=strain; } // Power down the strain gauge function powerdown() { digitalWrite(sgSend,1);//pulse on for 60us }// End of powerdown function // Power up after sleeping function powerUp() { digitalWrite(sgSend,0); }
I am trying to measure the torque from a bicycle by measuring tension of the chain. A load cell will be cantilevered off of the frame and a idler wheel will pull the chain up by around 10 deg. I am thinking that the force pulling the pulley down will be around 20% of the total force in the chain. I would then like to use the measurement to drive a electric motor.
I may also use it to weigh our fat cat...
Thank you in advance
I have the same issue, it is fine with the 1v89.28 travis build but its broken with anything newer.