-
-
Ugh, guess what? Turning my router on and off seems to have fixed the issue.
What I'm trying to do is to
get
an URL a few times a day. If my Wifi needs to be reset along the way, will I need to tell the Pico to reset its connection too? So if I try and fail to get a response, will I need to reset the connection is what I mean. -
Thanks, I had a sinking feeling it's something to do with my Wifi.
I had a look on my router and it's seeing the Espruino and assigning it an IP address.
Output is:
["AT+CIFSR\r\n" =undefined ] "+CIFSR:STAIP,\"192" ] ".168.1.5\"\r\n+CIFSR:STAMAC,\"18:fe:34:9d:5" ] "2:14\"\r\n\r\nOK\r\n" null 192.168.1.5
-
Yes I think it's something stupid I'm doing. It connects to the WiFi but just won't get anything.
I tried substituting the URL for
172.217.169.14
which I think is the ip for google.com but got the same result.Thanks,
Here's my code:
digitalWrite(B9,1); // enable on Pico Shim V2 Serial2.setup(115200, { rx: A3, tx : A2 }); const http = require("http"); var wifi = require("ESP8266WiFi_0v25").connect(Serial2, function(err) { if (err) throw err; console.log("Connecting to WiFi"); wifi.connect(WIFI_NAME, WIFI_PASS, function(err) { if (err) throw err; console.log("Connected"); fetchData(); }); }); function fetchData() { console.log('Fetching data'); http.get("http://gomako.co.uk/hello.txt", function(res) { var contents = ""; res.on("data", function(data) { contents += data; }); res.on("close", function() { console.log(contents); }); }).on("error", function(e) { console.log("ERROR", e); }); }
-
Hi, I got one of the original Picos with wifi shim and have updated the firmware on the Pico to 2v01 using TI CC3000 Wi-Fi networking (I did try with the other one as well just to make sure). I checked the ESP firmware on the board and that is as follows
"AT version:0.25.0.0(Jun 12 2015 20:26:28)\r\nSDK version:1.1.2\r\ncompile time:Jun 17 2015 22:11:51\r\n\r\nOK\r\n"
I think it's the most stable version?When I do a simple GET request, it times out and throws an error, which varies from
code -6, not found
tocode -15, no response
I can access the endpoints through the browser/curl so I think that's ok. Am I missing something obvious? It's been a while since I did anything with my Pico and wifi so may have missed an update somewhere.
-
Thanks for the info @Robin I'll have a look at that to try and further my understanding.
Thanks for the code @Gordon and for the tip about finding the underlying code. I find it fun to dig about and try and understand these things, even if it usually comes to nothing! There is a lot of information about the chip here http://infocenter.nordicsemi.com/pdf/nRF52832_PS_v1.1.pdf which looks pretty exciting, so I'm going to mess about with it using the js interface and see what happens.
-
Thanks for the info. I'm messing about using the examples, but I don't really know what I'm doing to be honest. I keep
peek32()ign
at everything I can think of, but the returned values stay the same. I don't have ~much~ any experience with low level stuff.Is the code that does this on the Puck available somewhere for me to look at to try and understand it, or will that not really help?
-
Hi, not sure if this is the right place to post about this board. I have got one and think it's great and am looking forward to exploring it more.
I'm trying to figure out how to access the capacitive touch sensors but can't figure it out. I have looked at the
boards/smartibot.py
file and can't see anything mentioning about capacitive sensors like in thepuck.js
file. I am keen to explore the board and somehow figure this sort of stuff out but can't really get my head around it!Any guidance would be appreciated.
-
Ah nice, yes that would be good. I was thinking of putting a little script on my server to handle the api lookups and return all the data in one go so I wouldn't have to do the https -> http proxy either.
I've not really done anything with promises but it looks like a good place to start
Error handling ommited for keeping it simple.. but you should take care of it :)
Of course! ;-)
-
-
Hello all,
Firstly, I have searched the error message I'm getting and haven't been able to apply it to my case, so here goes...
I have built a little OLED Bitcoin price display thing and am connecting to cryptonator (via mrtimcakes https to http proxy) to get some prices. It all runs fine but after a few minutes I get the repeated error
Uncaught InternalError: Unable to create socket
.I poll the api once every 30 seconds and call a function to deal with the data. From what I understand this is a memory problem, but I'm at a loss as to how to progress. Code is here https://gist.github.com/gomako/bdac39e9616709aa952ac04d0d5de019 and looks a bit like dog vomit, so excuse me for that!
-
@tc I'm glad it came in useful. I don't think it's super accurate but if it gets the job done then that's ok!
-
I have just updated a thread where I was asking the same question http://forum.espruino.com/comments/13395796/
That will show you how to get the approximate readings (0 is North, -90 is West, 90 is East and 180 is South), so you will be able to use them in the rest of your code. I'd be interested to see it posted, good luck!
-
Digging up an old thread here, but I kind of got it working enough for what I want.
I did what was suggested an took four readings at N,S,E,W, averaged them and deducted them from what
Puck.mag()
gave me back, then I ran it through the function I had before and it gave me accurate enough readings for the headings (0 for North, 180 for South, -90 for West and 90 for East). They aren't super accurate, but I'm guessing that's because of the nearby magnetic fields etc.My code is below:
// Be sure to take your own readings for your own magnetic environment! const avg = { "x": -967, "y": 514, "z": 1762 }; Puck.magOn(); Puck.on('mag', function(xyz){ xyz.x -= avg.x; xyz.y -= avg.y; xyz.z -= avg.z; console.log((Math.atan2(xyz.y, xyz.x) * 180) / Math.PI); });
-
@user72031 You could have a look at this thread http://forum.espruino.com/conversations/297915/
-
-
I follow you to a point, but I don't know what you mean in this bit
Point the X axis North and take a reading, then point it South and take a reading. Do the same for the Y axis.
Do I have the puck flat on a level surface and align it to North and South do the X axis (like turning a knob), then do I tip it on it's side and turn it (like a spinning coin) to do the same for Y?
-
I have been trying to advertise as various things from the Puck, but the only things I can get to show up as being described properly in nRF are the examples, Temperature and Battery Life. I can't get blood pressure or environmental sensing to show up. I think you have to provide a byte array as data which has some required parameters for some services, but I don't know how to tell what data it needs or how to give it to it! The eddystone example works too, and that has a load of bytes in an array.
NRF.setAdvertising([0x03, // Length of Service List 0x03, // Param: Service List 0xAA, 0xFE, // Eddystone ID 0x13, // Length of Service Data 0x16, // Service Data 0xAA, 0xFE, // Eddystone ID 0x10, // Frame type: URL 0xF8, // Power 0x03, // https:// 'g','o','o','.','g','l','/','B','3','J','0','O','c'], {interval:100});
I don't really understand the gatt spec website either.
-
I've been (unsuccessfully) trying to convert the magnetometer readings to a compass headings. I've been googling, and due to my maths education stopping at GCSE level, I don't understand most of the conversions. I tried following the adafruit guide but it's for a different magnetometer sensor, and the readings don't seem the same, Adafruit guide says the readings are in micro-Teslas and will be between 20 and 60 micro Teslas, and in the Puck guide it's saying a similar number, but that the increments are in 0.1 micro Teslas. I am getting readings of
{ "x": -3431, "y": 4167, "z": 508 }
so even divided by 10 these are off.I thought that the following code might work:
Puck.on('mag', function(xyz){ console.log((Math.atan2(xyz.y/10,xyz.x/10) * 180) / Math.PI); });
But I don't get the readings I would expect.
Am I missing something or being a dope?
-
@Gordon Ah right ok. If the Puck gets disconnected does the power consumption go back down again? i.e. If the computer it's connected to gets shut down, does it go back to broadcasting again?
Personally I think it's better to let the code decide when it should shut off BT. Although if there was a
Puck.sleep(timeToWaitBeforeSleeping)
sort of option that would be good? -
@Gordon Ah I was just going to ask that. Is this code going to give me the 2 years-ish figure?
setWatch(function(e) { controls.playpause(); }, BTN1, { repeat: true, debounce : 50, edge: "rising" });
-
@Gordon ah ok thanks. I don't really know much about BT, but I am learning. And yes, I've just tried the HID play button and it works great. Just need to
Remove
when I want to reprogram it. Looking forward to debugging when it's connected. It's about time I bought a USB TTL cable! -
@Gordon I had forgotten that I did it. Oops! It was working on my laptop messing about with lots of different stuff and working fine, the problem arose when I was using it on my iMac (which I had set up with the HID code and paired with). I haven't tried it as a HID button again yet.
I will try it again and let you know. Am I right in thinking I have to disconnect from Web Bluetooth and pair with the system OS to get HID to work as expected?
-
@François Will try and help.
- Yes, Puck is still in the os x bluetooth menu when Chrome is closed.
- I mean that I disconnect (not remove) the Puck from the os x bluetooth menu, then
a couple of seconds later it is back on the menu in bold (meaning
that the Puck has connected again) this is whether chrome is open or
closed. - Yep, I tried the re-scan link and it didn't show up.
- I am at work and can't test on Canary, but will update this post when I am home.
From what I understand. If the Puck is connected to something, it stops advertising, and so doesn't show up to anything else that you scan with, whether it's a phone, different computer etc. I may well be wrong, but that's how it looks.
I think that the issue may have arisen when I tried to make my Puck into a Play/Pause button (HID). I uploaded the code, then disconnected from the Web IDE, then connected via the os x bluetooth menu, as I reasoned that the os would need to connect for it to be able to control the media player. After that point, even if I reset the code to default (battery out, hold button down etc.) then os x saw that it had connected to the device before and just grabbed it when it was being advertised, which is why I needed to make os x forget the device completely so I could pair again in Chrome. I think that if I was quick enough, I probably could have connected via Web Bluetooth before os x did, (after disconnecting the device).
So yes, I think the way that you reproduced it was the same reason my Puck wasn't showing up.
- Yes, Puck is still in the os x bluetooth menu when Chrome is closed.
I had a similar issue. I disconnected the bangle from my iPhone (turned iPhone BT off) and then the Bangle showed up in the connection list on chrome.