Friday 30 March 2018

RC-CAr with Cayenne IOT Program.

2018-03-30
Starting from Raspian Jessie with fixed IP address.

In my folders this is Robot-6-Cayenne

https://mydevices.com/cayenne/landing/create-raspberry-pi-projects-with-cayenne/

First problem: It needs an app on a tablet. Have that.

It didn't work at first. I went in and deleted the /etc/webiopi/config file from the initial webIOPi configuration and then it connected.

Cayenne is NOT going to work  with my setup as is because 3 GPIO  pins are labelled as SPI pins and cannot be changed to I/O pins so I cannot control my left/right turning.   These are GPIO 9,10 and 11.

I am still not certain that I could have had it working without Internet access.

I need to find out how to delete Cayenne so that I can use the R-Pi for another technique without having to flash it all again and start from scratch.










Thursday 29 March 2018

Webiopi upgrade from Wheezy to Jessie

DECISION: Forget WebIOPi on Jessie. Let's do the next two things:
1. Cayenne.
2. AD-Hoc Networking

----------- ------------ ---------


Webiopi was working on a card with Raspbian Wheezy, then I updated  and upgraded and I noticed that some files were labelled from Jessie.

After rebooting I couldn't get Webiopi to load. I could ssh into teh R-pi as normal, so I started the WebioPi service but I stiull could not load the web page. What follows is the log for WebIOPi. I'll look at it later to see if I can understand what to do.

2018-01-14 14:17:27 - WebIOPi - INFO - Starting WebIOPi/0.7.1/Python3.4
2018-01-14 14:17:27 - WebIOPi - INFO - GPIO - Native mapped to REST API /GPIO
2018-01-14 14:17:27 - WebIOPi - INFO - Loading configuration from /etc/webiopi/config
2018-01-14 14:17:28 - WebIOPi - INFO - Loading myproject from /home/pi/rc-car/python/script.py
2018-01-14 14:17:28 - WebIOPi - INFO - Access protected using /etc/webiopi/passwd
2018-01-14 14:17:28 - WebIOPi - INFO - HTTP Server binded on http://192.168.1.8:8000/
2018-01-14 14:17:28 - WebIOPi - INFO - CoAP Server binded on coap://192.168.1.8:5683/
2018-01-14 14:17:28 - WebIOPi - INFO - CoAP Server binded on coap://224.0.1.123:5683/ (MULTICAST)
2018-01-14 14:17:37 - WebIOPi - INFO - Starting WebIOPi/0.7.1/Python3.4
2018-01-14 14:17:37 - WebIOPi - INFO - GPIO - Native mapped to REST API /GPIO
2018-01-14 14:17:37 - WebIOPi - INFO - Loading configuration from /etc/webiopi/config
2018-01-14 14:17:37 - WebIOPi - INFO - Loading myproject from /home/pi/rc-car/python/script.py
2018-01-14 14:17:37 - WebIOPi - INFO - Access protected using /etc/webiopi/passwd
2018-01-14 14:17:37 - WebIOPi - INFO - HTTP Server binded on http://192.168.1.8:8000/
2018-01-14 14:17:37 - WebIOPi - INFO - CoAP Server binded on coap://192.168.1.8:5683/
2018-01-14 14:17:37 - WebIOPi - INFO - CoAP Server binded on coap://224.0.1.123:5683/ (MULTICAST)
2018-01-14 14:17:28 - WebIOPi - INFO - Starting WebIOPi/0.7.1/Python3.4
2018-01-14 14:17:28 - WebIOPi - INFO - GPIO - Native mapped to REST API /GPIO
2018-01-14 14:17:28 - WebIOPi - INFO - Loading configuration from /etc/webiopi/config
2018-01-14 14:17:29 - WebIOPi - INFO - Loading myproject from /home/pi/rc-car/python/script.py
2018-01-14 14:17:29 - WebIOPi - INFO - Access protected using /etc/webiopi/passwd
2018-01-14 14:17:29 - WebIOPi - INFO - HTTP Server binded on http://192.168.1.8:8000/
2018-01-14 14:17:29 - WebIOPi - INFO - CoAP Server binded on coap://192.168.1.8:5683/
2018-01-14 14:17:29 - WebIOPi - INFO - CoAP Server binded on coap://224.0.1.123:5683/ (MULTICAST)
2018-03-29 15:14:21 - WebIOPi - INFO - Stopping...
2018-03-29 15:14:22 - WebIOPi - INFO - CoAP Server stopped
2018-03-29 15:14:22 - WebIOPi - INFO - HTTP Server stopped
2018-03-29 15:14:52 - WebIOPi - INFO - Starting WebIOPi/0.7.1/Python3.4
2018-03-29 15:14:52 - WebIOPi - INFO - GPIO - Native mapped to REST API /GPIO
2018-03-29 15:14:52 - WebIOPi - INFO - Loading configuration from /etc/webiopi/config
2018-03-29 15:14:52 - WebIOPi - ERROR - name 'GPIO' is not defined
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/WebIOPi-0.7.1-py3.4-linux-armv6l.egg/webiopi/__main__.py", line 75, in
    main(sys.argv)
  File "/usr/local/lib/python3.4/dist-packages/WebIOPi-0.7.1-py3.4-linux-armv6l.egg/webiopi/__main__.py", line 69, in main
    server = Server(port=port, configfile=configfile, scriptfile=scriptfile)
  File "/usr/local/lib/python3.4/dist-packages/WebIOPi-0.7.1-py3.4-linux-armv6l.egg/webiopi/server/__init__.py", line 52, in __init__
    self.gpio.addSetups(config.items("GPIO"))
  File "/usr/local/lib/python3.4/dist-packages/WebIOPi-0.7.1-py3.4-linux-armv6l.egg/webiopi/devices/digital/gpio.py", line 62, in addSetups
    self.addGPIOSetup(gpio, params)
  File "/usr/local/lib/python3.4/dist-packages/WebIOPi-0.7.1-py3.4-linux-armv6l.egg/webiopi/devices/digital/gpio.py", line 55, in addGPIOSetup
    self.addGPIO(self.gpio_setup, gpio, params)
  File "/usr/local/lib/python3.4/dist-packages/WebIOPi-0.7.1-py3.4-linux-armv6l.egg/webiopi/devices/digital/gpio.py", line 45, in addGPIO
    func = GPIO.OUT
NameError: name 'GPIO' is not defined


There's one thing -->  GPIO is not defined.

things to try:
https://raspberrypi.stackexchange.com/questions/37327/global-name-gpio-is-not-defined-errors-on-webiopi

At the bottom of this is the suggestion that I start WebIOPi specifically via Python3. This gives the webIOpi menu and GPIO pin display, but doesnt operate them.  It didn't start my web page.


Commands:
 sudo /etc/init.d/webiopi stop
sudo python3 -m webiopi 8000
gives when stopped: 
pi@raspberrypi:/var/log $ sudo python3 -m webiopi 8000

2018-03-30 10:41:36 - WebIOPi - INFO - Starting WebIOPi/0.7.1/Python3.4

2018-03-30 10:41:36 - WebIOPi - INFO - GPIO - Native mapped to REST API /GPIO

2018-03-30 10:41:36 - WebIOPi - WARNING - Access unprotected

2018-03-30 10:41:36 - WebIOPi - INFO - HTTP Server binded on http://192.168.1.8:8000/

2018-03-30 10:41:36 - WebIOPi - INFO - CoAP Server binded on coap://192.168.1.8:5683/

2018-03-30 10:41:36 - WebIOPi - INFO - CoAP Server binded on coap://224.0.1.123:5683/ (MULTICAST)

----------------------------------------

Exception happened during processing of request from ('::ffff:192.168.1.11', 46518, 0, 0)

Traceback (most recent call last):

  File "/usr/local/lib/python3.4/dist-packages/WebIOPi-0.7.1-py3.4-linux-armv6l.egg/webiopi/protocols/http
.py", line 238, in processRequest

    result = self.server.handler.do_GET(relativePath, compact)

  File "/usr/local/lib/python3.4/dist-packages/WebIOPi-0.7.1-py3.4-linux-armv6l.egg/webiopi/protocols/rest
.py", line 147, in do_GET

    return (200, self.getJSON(compact), M_JSON)

  File "/usr/local/lib/python3.4/dist-packages/WebIOPi-0.7.1-py3.4-linux-armv6l.egg/webiopi/protocols/rest
.py", line 245, in getJSON

    gpios[gpio][f] = GPIO.getFunctionString(gpio)

NameError: name 'GPIO' is not defined
And lots more repeats of this. 
???? 
Possibly this, but doesn't mention Jessie
http://webiopi.trouch.com/issues/140/

This first I think:
https://groups.google.com/forum/#!topic/webiopi/BGc-mcD3UEw
-- It won't work. My version number is the one already in the file.


Wednesday 28 March 2018

Second RC Car

MArch 2018,
I have another RC car that I have modified to be driven by a Raspberry Pi. I am using the same RAspberry Pi and software as I did on the first.

Here is a picture of the rig.

The Hot glue gun is my new favourite tool. I used tabs of glue to hold this battery pack in, and glued the plastic battery holder (white plastic) to the body for the power pack

The electronics are simpler than on the previous car, as there are no feedback wires from the steering gear.  


The IC is labelled RX2C which I take to mean receiver-2-channel and from the schematic I found which pins were the outputs to the motors, as labelled.



Here is the layout on the car. I brought the wires from underneath out to a strip of pins, and labelled them so that I can easily swap them out to try another controller if I get one. The leads from the Raspberry Pi are visible also coming from the GPIO pins to what had been the IC legs, replaced with pins.  To have been tidier I should have bought some leads, but I just quickly cobbled these together. 

It took a bit of testing to get these pins on the pin-strip correct, and the car turning left/right or backwards/forwards as desired. If I did it again I would put the Positive  and Ground leads at either end of the strip to separate them. 

Next thing to do is add a Youtube video of it in operation, then swap the controller board out for this Deek-Robot H Bridge controller that I have bought. 



Wednesday 7 March 2018

Challenge for DT in Secondary Schools.

How about 'Dorset Robo-Challenge  Modelled on Robot wars, with competitions within the school throughout the year and an Interschool competition at the end of the year. 

To make it interesting all robots to be controlled by Raspberry Pi, Micro:bot, or Arduino.

Obviously it needs some 'House' robots and pitfalls. I think a sideswiping axe from the middle of one side of the competition chamber and a box that has sides that flip up to enclose the 'bot when it gets on the centre.

Get local companies to provide a technical champion for each team?