Avatar for seanclark

seanclark

Member since Jul 2017 • Last active Sep 2017
  • 2 conversations
  • 19 comments

I am a digital artist, the Founder and Managing Director of web/mobile developer Cuttlefish, the Director of Leicester arts company Interact Digital Arts, a Visiting Researcher at the Institute of Creative Technologies at De Montfort University in the UK and an International Professor at GuangDong University of Technology in China. Want to talk about projects? Get in touch.

Most recent activity

  • in Pico / Wifi / Original Espruino
    Avatar for seanclark

    Hi Gorden,

    When you say "printing to USB" would "console.log" be included? Not that I'm printing much, just error messages.

    Is there a maximum length on MQTT topic and message lengths? Again, they don't strike me as too long but I could be over doing it. Is it OK to put stringified JSON in an MQTT message on Espruino? I'm not doing it at the moment, but am thinking of doing so.

    Also, I was wondering about using "tinyMQTT". Is there any advantage in using this over the native "mqtt"? I notice in the docs that this does have a "127 byte publishing length limit" though. Is this topic and/or message?

    I'll keep exploring. It's not causing me major problems. Currently my Espruino has been up for 21 hours, processed 841 packets and only had 6 bad packets. It would be nice to get to the bottom of it though!

    Sean

  • in Pico / Wifi / Original Espruino
    Avatar for seanclark

    Hi,

    I was getting it on both firmwares, here is a log showing bad packets. For some there are no flags, but a few are showing LOW MEMORY:

    bad packet [FE3100FFFD3100FFE33100FFE53100FFD931
    +IPD,0,90:0Xbiosphere/ecology/matrix/col­or8B3100FF743100]
    [  ]
    bad packet [ biosphere/ecology/matrix/color743100FF75­3100FF763100FF773100FF783100FF853100]
    [  ]
    bad packet [F13100FFEE3100FFD13100
    +IPD,0,82:0Pbiosphere/ecology/matrix/c]
    [
      "LOW_MEMORY"
     ]
    bad packet [6A3100FF893100FFB73100FFE73100
    +IPD,0,42:0(biosphere/ecology/matrix/col­or5C3100FF
    +IPD,0,114]
    [  ]
    bad packet [145FFF00155FFF0000]
    [  ]
    bad packet [745FFF008B5FFF00945FFF00955FFF00AA5FFF0­0A95FFF00A85FFF00985FFF00865FFF007A5FFF0­0435FFF003C5FFF00235FFF001C5FFF00035FFF0­0
    +IPD,0,227:0à]
    [
      "LOW_MEMORY"
     ]
    

    Sean

  • in Pico / Wifi / Original Espruino
    Avatar for seanclark

    I've tried the alternative firmware and - you're right - it makes the neopixels act a little randomly, with flashes and unpredictable colour changes!

    I've improved my script quite a bit since my earlier post. I now use a node.js server to batch up my colour changes and only release them to the Espruino via MQTT after a predetermined time. I've currently set this to 250ms to give the Espruino time to update the neopixels.

    This mostly works very reliably, however I sometimes get errors in my packets. The basic neopixel packet is 12 hex characters, with multiple packets being grouped together. Here is a run of correct packets:

    [0000E1FF0000]
    [0000E2FF00000000DCFF00000000DAFF0000000­0C6FF00000000C8FF00000000B5FF00000000B4F­F00000000B2FF00000000ADFF00000000AEFF000­00000AFFF0000]
    [0000AEFF00000000ADFF00000000ACFF0000000­095FF0000]
    

    However, every now and then I get some erroneous data in the packet. It appears to be the MQTT topic, eg. "biosphere/ecology/matrix/color", preceded by text in the form "+IPD,0,70:0". As you can see from the example below, this erroneous data is stuck in the middle of a packet.

    [000085FF000000000052FF000000006DFF00000­00071FF000000008EFF0000
    +IPD,0,70:0Dbiosphere/ecology/matrix/col­or000091FF00000000AEFF00000000ADFF0000
    +IPD,0,46:]
    

    Any thoughts about what the problem might be? Like I say, I'm only sending a packet every 250ms now and they are at the very most 100 or so characters.

    Sean

  • in Pico / Wifi / Original Espruino
    Avatar for seanclark

    I've just gone to install the new firmware, but I'm not sure which on in the list to use? Is it the specific _wifi one?

    Sean

    • 4 comments
    • 3,567 views
  • in Pico / Wifi / Original Espruino
    Avatar for seanclark

    The idea of routing/bridging packets between socket.io (for web browsers) and MQTT (for Espruino) via node.js works really well. It provides a very nice way for my web-based artworks to communicate with microcontroller-based ones. I think I could probably move completely over to MQTT (on the browser too) but for now I'll stick with what I have produced.

    My next step is to sort out the lost packets when using neopixels (with that test version of the library) and get DMX light control working.

    Still loving the platform!

    Sean

  • in Pico / Wifi / Original Espruino
    Avatar for seanclark

    Thanks Gordon,

    I was going to look at MQTT next - it sounds like the way to go.

    Cheers,

    Sean

  • in Pico / Wifi / Original Espruino
    Avatar for seanclark

    I use socket.io to enable browser to browser communication in a number of projects.

    For example, a client running in Chrome might include:

    	var socket = io();
    	socket.on('matrix', function(packet) {
    		// Process packet
    	});
        socket.emit('register',{'artworkid': artworkid, 'artworktype': artworktype});
    
    

    And on the node.js server. This would "bounce" the messages between clients:

    io.on('connection', function(socket) {
      console.log('Connected');
      socket.on('disconnect', function() {
        console.log('Disconnected');
    	console.log("Clients: "+Object.keys(io.sockets.clients));
      });
    
      socket.on('register', function(msg) {
      	socket.artworkid = msg.artworkid;
      	socket.artworktype = msg.artworktype;
      	console.log("Registered: "+msg.artworkid+" "+msg.artworktype);
      });
    
      socket.on('matrix', function(msg) {
      	socket.broadcast.emit("matrix", msg);
        //console.log("matrix: "+msg);
      });
    });
    

    How do I get a client running on the Espruino to join in? I don't think there is a socket.io library for Espruino so do I need to use ordinary sockets to do the same job? Would I need to take messages received in socket.io and resend them to the Esprunio and visa versa? Are there some good examples of Espruino to node.js communication via sockets that I should be looking at?

    Thanks,

    Sean

  • in Pico / Wifi / Original Espruino
    Avatar for seanclark

    Another thought. If a network packet is lost during the update of the neopixels is there a way of the sender knowing? At the moment I'm not getting an error message. Should I implement some sort of "acknowledge" on the Espruino so that the sender knows when to resend a packet?

    Sean

Actions