-
-
@allObjects thanks. I was brain storming an idea. Code an object called "pages" and store text, font size for different pages. Each pcb button will be a different page that contains graphic data(text, color, font and etc)
-
-
-
I'm getting Failed to start EspruinoHub BLE -> MQTT and I am not sure how to fix the issue.
I followed the Auto Start guide for a Headless Startup
Output:
-- Logs begin at Thu 2016-11-03 17:16:43 UTC. -- Sep 30 19:08:05 raspberrypi systemd[1]: Started EspruinoHub BLE -> MQTT bridge. Sep 30
19:08:05 raspberrypi EspruinoHub[10792]: setterm: $TERM is not
defined. Sep 30 19:08:05 raspberrypi sudo[10805]: pi :
TTY=unknown ; PWD=/home/pi/E
spruinoHub ; USER=root ; COMMAND=/sbin/setcap cap_net_raw+eip
/usr/bin/node Sep 30 19:08:05 raspberrypi sudo[10805]:
pam_unix(sudo:session): session opened
for user root by (uid=0) Sep 30 19:08:05 raspberrypi sudo[10805]:
pam_unix(sudo:session): session closed
for user root Sep 30 19:08:05 raspberrypi EspruinoHub[10792]:
Config loaded Sep 30 19:08:06 raspberrypi EspruinoHub[10792]:
Connecting... Sep 30 19:08:06 raspberrypi EspruinoHub[10792]:
Server is listening on ht
tp://localhost:1888 Sep 30 19:08:06 raspberrypi EspruinoHub[10792]:
www directory found at /h
ome/pi/EspruinoHub/www. Web server at http://localhost:1888 Sep 30
19:08:06 raspberrypi EspruinoHub[10792]: log directory found
at
/home/pi/EspruinoHub/log. Enabling logging. Sep 30 19:08:06
raspberrypi EspruinoHub[10792]: events.js:183 Sep 30 19:08:06
raspberrypi EspruinoHub[10792]: throw er; // Unhandled 'er
ror' event Sep 30 19:08:06 raspberrypi EspruinoHub[10792]: ^ Sep
30 19:08:06 raspberrypi EspruinoHub[10792]: Error: listen EADDRINUSE
:::1888 Sep 30 19:08:06 raspberrypi EspruinoHub[10792]: at
Server.setupListenHandle
as _listen2 Sep 30 19:08:06 raspberrypi
EspruinoHub[10792]: at listenInCluster (net.js:1
401:12) Sep 30 19:08:06 raspberrypi EspruinoHub[10792]: at
Server.listen (net.js:148
5:7) Sep 30 19:08:06 raspberrypi EspruinoHub[10792]: at
Object.exports.init (/hom
e/pi/EspruinoHub/lib/http.js:125:10) Sep 30 19:08:06 raspberrypi
systemd[1]: EspruinoHub.service: Main process exited
, code=exited, status=1/FAILURE Sep 30 19:08:06 raspberrypi
systemd[1]: EspruinoHub.service: Unit entered failed
state. Sep 30 19:08:06 raspberrypi systemd[1]: EspruinoHub.service:
Failed with result
'exit-code'. Sep 30 19:08:07 raspberrypi systemd[1]:
EspruinoHub.service: Service hold-off ti
me over, scheduling restart. Sep 30 19:08:07 raspberrypi systemd[1]:
Stopped EspruinoHub BLE -> MQTT bridge. Sep 30 19:08:07 raspberrypi
systemd[1]: Started EspruinoHub BLE -> MQTT bridge. Sep 30 19:08:07
raspberrypi EspruinoHub[10839]: setterm: $TERM is not defined. Sep 30
19:08:07 raspberrypi sudo[10846]: pi : TTY=unknown ;
PWD=/home/pi/E
spruinoH -
@Gordon Thank you soooooo much for taking a look at the W5100 issue. I will be purchasing the ethernet shield from ebay in the next couple of days and report back with my findings :-)
-
Do mean that it would update the others while they are deployed and
running?Yes, Lets say there is an updated espruino firmware where I would usually open the web ide and upload the new firmware via the "Flasher" section. I was wondering if it is possible to update the firmware using another espruino device.
The reason for my question is, I have a pixl.js which is a fun little device, but it has a minor issue when using an ethernet shield. Apparently the pixl will hang for about 30 seconds after I think a socket disconnect. I'm not sure if that issue still exists as I don't have an ethernet shield at the moment.
To possibly mitigate against that issue, I wanted to see if I can combine my existing pico + wiznet into my pixl project. Let the pico handle the network logic and let the pixl handle the bluetooth and other logic. Or maybe this is not needed/redundant?
The pico and] pixl will communicate I guess over i2c.. or maybe serial.... I'm not exactly sure yet.
Now, I thought when there are firmware updates for the espruino boards, how can I update the firmware without having to connect to the IDE?
-
-
Can anyone recommend an arduino relay shield that has two or more channels that can be used on a pixl.js? I was looking at: https://m.seeedstudio.com/productDetail/2440 but im not sure if that will work safely with the pixl.
-
@Jean-Philippe_Rey
Thank you for the recommendation. I will look into this.@Gordon I have a couple of those converters laying around. Both can power 3.3v and 5v. Im assuming 3.3v option is what I should use?
-
-
I'm wanting to get the Pixl.js for my current project that I am working on, plus I want to learn about bluetooth. I am basically going to use the pixl to show my computer status(cpu, mem and etc...) and also send the values to my cell phone via bluetooth.
Will I be required to program the pixl over bluetooth instead of using usb? I also want to get my computer values using usb serial then print them out onto the lcd. Will I need to use a FTDI to achieve this?
-
-
@Gordon Ok, I can view the file. Not sure what happened before.
-
@Gordon I'm on my lunch break and wanted to check out the source code:
https://raw.githubusercontent.com/espruino/EspruinoDocs/master/modules/MQTT.jsBut, I'm getting 404: Not Found
-
Update to my last post
I closed my Electron APP so there are no more mqtt messages being sent. I let the Espruino IDE just idle for a few minutes and I received multiple "PING" in the console. My mosquito log now shows PINGREQ and PINGRESP from the PICO.
PING seems to halt when messages are being received. To test this I opened my app again, after a few messages I get the same disconnected... reconnecting message. I then closed my app and PING seems to resume again and so does the PINGREQ and PINGRESP in my mosquito log file.
I also downloaded a chrome extension called mqttbox. I'm manually sending the same MQTT message using mqttbox every 30 seconds and again I'm getting the same disconnected... reconnecting. message in the console. I then just sent one message from mqttbox and waited... PING continued to resume without getting and MQTT disconnected... reconnecting. message.
I seem to not get the MQTT disconnected... message for any message received that was sent after 60 seconds. For example, I can send one message every 65 seconds and still receive a PINGREQ properly.
For my project the PICO doesn't need to receive EVERY single message over my mqtt network. Just only messages pertaining to the PICO; however, I will still run into the disconnected... issue if messages are received inside the 60 seconds keepalive window.
-
Nevermind about that error. I moved the code into the onInit() function and only received one "PING" inside of the console. After the third mqtt message I get:
MQTT disconnected... reconnecting.
MQTT connectedI typed
mqtt.ping()
into the console and received "PING". I manually executedmqtt.ping()
a few times and I haven't received those errors as of yet. So, I'm wondering if the PICO isn't pinging mosquito. To test that, I didn't manually ping the broker and after three messages I get:MQTT disconnected... reconnecting.
MQTT connected -
@Gordon You are definitely onto something.
I turned on verbose logging in mosquito. I didn't see a PINGREQ or a PINGRESP for the PICO. I uploaded a screen shot. I wish the log file wasn't so cluttered and easier to read/understand. PICO IP is now 192.168.0.89. I setup static IP for the PICO because I thought there might be an ip conflict, possibly causing that error, but that's not the case.
I am sending "Hello World!" mqtt message from the pico every 10 seconds. The Pico seems to work as expected WITHOUT those errors as I described earlier :-) I then commented out the setInterval and uploaded the code again. Now the PICO is disconnecting with the same error message :-(
It couldn't hurt for me to send an 'OK' message every few seconds from the PICO to nodered to keep everything up and running properly.
-
What's the IP of the Espruino that's connecting?
192.168.0.18
And do you know what mqttjs_18553fd6 is?
I created an Electron App using the mqttjs module. My Electron app just sends a mqtt message every 30 seconds with updates about the status of my computer.
Electron App code:
const shutdown = require('electron-shutdown-command'); var lockYourWindows = require('lock-your-windows'); var mqtt = require('mqtt'); var client = mqtt.connect('mqtt://192.168.0.17', [{protocolId: 'MQTT'}]); client.on('connect', function () { client.subscribe('#'); }) client.on('message', function (topic, message) { // message is Buffer var msg = message.toString(); //console.log(topic.toString()); if(msg == "lockscreen") { var isLocked = lockYourWindows.isLocked(); lockYourWindows.lock(); } if(msg == "shutdown") { //shutdown.logoff(); } if(msg == "logoff") { shutdown.logoff(); } }); function isScreenLocked() { var isLocked = lockYourWindows.isLocked(); var v = isLocked ? 1 : 0; client.publish('/mydevice/lockscreen/status', v.toString()); } // Ever 30 seconds send a MQTT msg to nodered to update the Lockscreen Status Guage setInterval(isScreenLocked, 30000);
Espruino IDE console:
MQTT=> /mydevice/lockscreen/status 0
MQTT=> /mydevice/lockscreen/status 0
MQTT=> /mydevice/lockscreen/status 0
MQTT disconnected... reconnecting.Here is a new log:
1533770037: New connection from 192.168.0.18 on port 1883. 1533770037:
New client connected from 192.168.0.18 as 4de309a8004f (c1, k60).
1533770095: Client a7c51f6bdcc7 has exceeded timeout, disconnecting.
1533770095: Socket error on client a7c51f6bdcc7, disconnecting.
1533770363: New connection from 192.168.0.9 on port 1883. 1533770363:
New client connected from 192.168.0.9 as mqttjs_6ce48170 (c1, k60).
1533770480: Client 4de309a8004f has exceeded timeout, disconnecting. -
Ok - so this is unrelated to the recent changes then?
If I understood your question correctly... after about 3 messages I receive: MQTT disconnected... reconnecting for both
mqtt = require("MQTT").connect({
andrequire("https://raw.githubusercontent.com/espruino/EspruinoDocs/master/modules/MQTT.js").connect({
For the sake of debugging this, should I just use the normal
require("MQTT")
?What MQTT server are you using?
I followed your guide: http://www.espruino.com/Home+Automation , I am using mosquitto.
Could you see if you can read the logs for it? It's entirely likely it
doesn't like something that Espruino's MQTT client is doing, and so it
drops it.exceeded timeout and Socket error on client is what stood out the most. You are probably right, the mqtt broker doesn't like what the Espruino's MQTT client is doing, and so it drops the connection. I'm really not sure why or what the Socket error means and why I've exceeded the timeout, disconnecting. I executed mqtt in the console which spits out "keep_alive": 60 so, I'm not sure why it keeps timing out. So I can understand the keep_alive setting, does the Espruino mqtt client ping every 60 seconds to keep the session alive?
Log segment:
1533682953: New connection from 192.168.0.18 on port 1883.
1533682953: New client connected from 192.168.0.18 as 3b2ac31a3c98 (c1, k60).
1533683015: New connection from 192.168.0.9 on port 1883.
1533683015: New client connected from 192.168.0.9 as mqttjs_18553fd6 (c1, k60).
1533683016: Client 768aa6e0d3bc has exceeded timeout, disconnecting.
1533683016: Socket error on client 768aa6e0d3bc, disconnecting.
1533683121: Client 3b2ac31a3c98 has exceeded timeout, disconnecting. -
That's interesting - what happens if you switch back to the original
MQTT?I executed
reset(true)
changed the mqtt require tomqtt = require("MQTT").connect
then uploaded my code.
after about 3 mqtt messages I get: MQTT disconnected... reconnecting. Then mqtt reconnects with message MQTT connectedYou could try replacing:
I changed the code with your suggestion, executed reset(true) then uploaded the code.
After about 3 messages I receive: MQTT disconnected... reconnecting. Then mqtt reconnects with message MQTT connectedcode:
var MQTT_HOST = "192.168.0.17"; var PATH = "/mydevice/"; var mqtt; var eth; var inProcess = false; var shortPress = 1000; // ms 1 sec var longPress = 5000; // ms 5 secs var pressPin = B3; // output like 'open collector' see reference pinMode(pressPin,"opendrain"); pressPin.set(); function mqttMessage(pub) { console.log( "MQTT=> ",pub.topic,pub.message); if (pub.topic==PATH+"computer") { if (pub.message == "shutdown") { press(shortPress); } } } function mqttConnect() { console.log("mqttConnect"); mqtt = require("MQTT").connect({ host: MQTT_HOST, }); mqtt.on('connected', function() { console.log("MQTT connected"); // subscribe to wildcard for our name mqtt.subscribe(PATH+"#"); }); mqtt.on('publish', mqttMessage); var thisMQTT = mqtt; mqtt.on('disconnected', function() { if (mqtt!=thisMQTT) { console.log("MQTT disconnected - but we already have a new MQTT"); return; } console.log("MQTT disconnected... reconnecting."); setTimeout(function() { mqtt.connect(); }, 1000); }); } function press(short) { // ignore press function when one is still going on if (inProcess) return; inProcess = true; // Relays (board) act in an inverse manner // reset() will latch the relay pressPin.reset(); setTimeout(function(){ // Relays (board) act in an inverse manner // set() will unlatch the relay pressPin.set(); inProcess = false; },(short) ? shortPress : longPress); } setWatch(function(e) { digitalWrite(LED1, e.state); press(shortPress); }, BTN, { repeat: true }); function onInit() { console.log("Connecting to Ethernet"); SPI2.setup({ mosi:B15, miso:B14, sck:B13 }); eth = require("WIZnet").connect(SPI2, B10); isConnected = eth.setIP(); if (isConnected == true) { mqttConnect(); } }
Is it good practice to execute reset(true) before I upload any new code in the future?
I came across this article while reading my morning tech news: https://www.zdnet.com/article/how-to-boost-your-bluetooth-signal-to-cover-your-entire-home-or-office/
Does anyone know if such a device would work with any of the bluetooth enabled espruino boards?