-
Thanks @allObjects. You are right and I think i have it sussed.
The alpha/compass was a red herring I also came to conclusion it is not possible to use that alone. It seems the beta data will give me what I need as it still works when phone is held landscape and when tilted, I didn't cotton on to that initially.
Re the other controls, the screen will display an SVG steering wheel. With the following controls start/stop, toot, honk (we have a buzzer as horn, which also toots when connected to wifi), and drive reverse. I'm building it as a riot.js component for easy implementation & reuse so will share when done.
I've attached a pic showing of the WIP wheel and also attached the "new" car. Made some good progress since your help in the other thread, and it's been so easy to work on - look at all the space!
-
Not specifically Espruino but hoped to pick the forums brains.
I'm trying to use browser deviceorientation API to control an RC car running Espruino.
I was using the beta and gamma change events so the steering would work with tilting the phone left and right of the horizontal, which I thought was fine, but on handing my phone to my youngest - he rotated it and starting to use the phone like a steering wheel. He was disappointed.
A UI lesson learned I'm now trying to use the alpha change event, which is basically using the phones compass I think?
So my problem/question. My problem is that steering needs to be relative to the position the phone starts in say facing 180 degrees. I can detect decrements and increments relative to that, no problem, to provide left and right events, but what if the user changes their orientation - as they might if following an RC car? The steering will start to go off. Same result if the phone starts from a angled position, my first bearing will be off so the steering will not be natural
I hope that makes sense. Has anyone done this? Is there a better approach?
-
Your example does not seem very complex, and you've obtained an IP address.
The only thing I typically would not have in my code is changing the clock speed. I don't know the implications of that - maybe none. Why do you do that out of interest?
But if this reboots after a set period, the first thing I'd check would be power. The NodeMCU should not need capacitors - at least I've never needed anything other than the board, but are you confident that the USB supply is providing enough power? Maybe try a wall mounted USB supply, and connect to the board over Telnet to upload the code.
You are probably aware you can permanently save wifi settings with
wifi.save()
which makes the boards very convenient to work with wirelessly. -
-
-
@Wilberforce, thanks, just seen this but looks like they are gone again. I think that's the way to do it though - get some other bits to make the shipping easier to palate..
-
-
Thanks both. Anyway, the project has changed slightly. Had about 20 minutes with it on Telnet just issuing commands in the console and it appears the steering servo is broke. I'm assuming it has stripped a gear, since it no longer makes either stop, the motor just spins. I've opened it up and everything is so tiny it is hard to see what might be damaged but there's no final drive on the arm. It was only a few quid on ebay, but reluctant to get another if it is not up to the job.
Kids however now sufficiently interested, to give me (actually sell me) another RC car - this one is much bigger and runs a motor for steering also, so both channels of the Hbridge board will be useful. It also has 4 * AA batteries so I'll have 6v to put into the NodeMCU, which I'm, hoping will be ok - and of course the body will go back on.
The camera idea is cool, I did see this being something that could be driven over the internet - and I fancied MQTT over port forwarding to a webserver running on the ESP8266 - and the camera would be a boon.
The custom PCB is also a great idea, but it all comes down to learning curves and time for me.
-
-
Some progress. I didn't build the H Bridge circuit. I went to Maplin asked about the bits needed and was met with glazed eyes - more glazed than mine! So I found this on ebay (see pic).
I have it wired and the best thing is it supports analog - so this micro RC car which had digital steering and drive now as analog running both.
My next challenge is to try run the lot on a 3.7v lipo attached the nodeMCU Vin - which "should" be for 5 volts. I've wired it and all the lights come on, but whether there's enough to run wifi and the H bridge plus motor I've no idea. Anyone?
If that works I'll refine the sketch and report back again.
Edit: Needless to say there is no way the body is going to go back on this car now.
-
Great, thanks for confirming that.
Looking at the module and the peer to peer example in @Gordon's link above, I also wondered how communications are secured. It looks like any module could listen and receive the transmission? And re the range - could we expect one of these RN2483 modules to a have the 10km range mentioned on ThingsNetwork or is there signal amplification on their modules?
-
Looks good - I'm interested in LoRaWAN but wasn't sure how to start - this is a great intro.
One question on mind as I read it. How do you know if you are in range of gateway? Can you ping them or something or do you just send and not assume message sent unless you get OK return? I guess you could send two messages, the first a test/ping, and if get OK then send real data?
-
Hey @Frida. Looking at the link, you have the LoPy which can also be a LoraWan hub? I know there's been some discussion on here about LoraWan modules - is the hardware on the chip compatible with this work?
There's also a WiPy on the website, which is built on ESP32 too, just $10 cheaper. I was impressed with the range figures they cite. I don't see 1km range advertised as part of ESP32 chipset specs, so would you know if this range assumes it's part of a LoraWan setup, or is it something they've added on the board which means we can expect a wifi access point or station to have this range?
Great that you've got it running too, and I've no doubt I'll ask you which pin set flash/boot mode at some point :)
-
Just a thought on this. Espruino on ESP8266 now has many more JSvars available to it than the early versions of the port did - and I've been meaning to try the core espruino MQTT module on it to see if it runs - but, back in day, on the development versions, the module was just too big to load and then run any sort of application on the back of.
The errors you mention here would suggest to me that it is still too big. Just wondering if merely dumping the connections options as you did was enough to keep within memory..
Can you check
process.memory
when your code is loaded/running? It would be interesting to know what "free" is. -
Thanks @Frida, I will check that out.
-
@Wilberforce There doesn't seem to be any supply at moment. I passed on the $15 Adafruit dev board a week back because of the shipping costs, but sort of wish I hadn't now. I haven't been able to find just the ESP32 (no dev board) anywhere either, and it seems the dev boards are now on preorder.
Do you have a link for the lopi? I thought they where just fulfilling the kickstarter at the moment.
-
Here you go. This is your path routing example.
var wifi = require("Wifi"); // All routing in here function router(req ,res){ var a = url.parse(req.url, true); res.writeHead(200,{'Content-Type': 'text/plain'}); p = a.path.split("/"); // Test for path formatted to set the temp if (p.length == 3 && p[1] == "set") { var temp = parseFloat(p[2]); res.write("The temp sent to the server was " + temp + "C"); } else { res.write("The request was not formatted to set the temp"); } res.end(""); } // When connected create webserver function createServer(){ var port = 8080; require("http").createServer(router).listen(port); console.log("Listening on " + wifi.getIP().ip + ":" + port); } // Connect to Wifi wifi.stopAP(); wifi.connect("xxxx", {"password":"xxxx"}, createServer);
-
Re the first example you'd want a key in the querystring something like ?temp=23
You'd then be able to access as a.query["temp"].
In your second I can see what you want to do but syntax not quite right. You'd split to a new variable for one thing.
Happy to give you the right code later - on a mobile currently- but this may help you
-
url.parse()
will give you all the information about request path and request querystring arguments so you can do all your routing in one handler. If you are making some form of UI to control this, you might also consider using AJAX so your control panel UI is not disappearing at each adjustment. There are a couple of examples on the espruino.com site.[Edit]
This is one, check out the
onPageRequest
handler examples is the server/pages section, where all path and querystring vars are parsed in one function:-
http://www.espruino.com/InternetAnd this one, which covers interactive UI, and makes ajax requests in background:-
http://www.espruino.com/Interactive+Web+UI -
-
Oh no. Sorry @wardy if I led you down the garden path there. My suggestion was based on a 433MHz radio module which I have and where a similar pulsing principle applies. That module has the 3 pins I spoke of. Sorry... a little knowledge is a dangerous thing :(
-
Nice tutorial!
Needless to say 3 pin pairs not enough - nothing from the motor. Wiring connected right since 2 leds worked fine. I've researched and the ESP8266 has only 12mA per pin and as best as I can tell (from trying to find the part on the web) is the motor needs 70mA at 4.5v. I'm inferring more at 3.3v based on P= V * I, or perhaps it will just run slower.
The good news is the micro servo works great. The linkage is tight enough, and the steering makes both of its stops. The servo module makes it a breeze to work with and the code is lightweight enough to fit in to my program which listens over MQTT and go in the ESP8266.
So next steps. Wait for the new control board to arrive which will have the H gate on and try piggy back that, so motor driven from the lipo battery. Or, failing that try find a smaller motor, maybe the type that goes in micro drone and try fudge that in, accepting that car will be slower if it can be made to work at all.
I can do neither currently so, I'll come back to this thread when I can.
-
It's an Apple iPhone and I don't know re your second question I'm afraid - whatever the iphone has built in.