Wednesday 23 December 2020

Realtek Dongle on Raspberry Pi

I bought one hoping that it would be a drop-in job to replace my Zyxel big dongle, but it isn't.

Dmesg shows  the dongle:

   5.343207] usb 1-1.2: New USB device found, idVendor=0bda, idProduct=f179, bcdDevice= 0.00
[    5.358273] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[    5.369210] usb 1-1.2: Product: 802.11n
[    5.376550] usb 1-1.2: Manufacturer: Realtek
[    5.384275] usb 1-1.2: SerialNumber: 00E0222F6C96

But that's as far as it goes.

lsusb gives:

pi@raspberrypi:~ $ lsusb
Bus 001 Device 004: ID 0bda:f179 Realtek Semiconductor Corp. 

lsmod shows some wifi stuff, but nothing definitive.

and iwconfig:

pi@raspberrypi:~ $ iwconfig
eth0      no wireless extensions.

lo        no wireless extensions.

A search shows that I have to build the driver:

https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=62371

I was hoping that I wouldn't have to do this, though the author indicates that he has made it as easy as possible. 

First step: 

pi@raspberrypi:~ $ uname -a
Linux raspberrypi 5.4.79+ #1373 Mon Nov 23 13:18:15 GMT 2020 armv6l GNU/Linux

This how-to dates from 2013 and only goes up to kernel 4.19, so I may have a difficulty. 

I note that the web page that it refers to has been updated to Raspbian Buster so may be OK. But it does only have driver files up to 4.1.15 #830, which is quite a difference.

There is a script to install the drivers. It is here.

http://www.raspberrypi.org/forum/viewtopic.php?p=479340#p479340

I downloaded it, and when I ran it I got the error message:

pi@raspberrypi:~ $ sudo sh ./realtek_install.sh  
cannot match kernel: 5.4.79+ #1373
please check news at http://www.raspberrypi.org/phpBB3/viewtopic.php?p=462982
or try closest compatible version with -k <kernel build>

I tried to download the latest version listed on the website, and got the error message.

pi@raspberrypi:~ $ wget https://dl.dropboxusercontent.com/u/80256631/8188eu-20151216.tar.gz
--2020-12-23 19:01:56--  https://dl.dropboxusercontent.com/u/80256631/8188eu-20151216.tar.gz
Resolving dl.dropboxusercontent.com (dl.dropboxusercontent.com)... 162.125.64.15, 2620:100:6020:15::a27d:400f
Connecting to dl.dropboxusercontent.com (dl.dropboxusercontent.com)|162.125.64.15|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2020-12-23 19:01:56 ERROR 404: Not Found.

 so now what. 

2020-12-28 

From: https://www.raspberrypi.org/forums/viewtopic.php?f=36&t=250911&p=1786240#p1786240


ran the instructions given by Engman on Sat Dec 26, and they seem to have worked. 

pi@raspberrypi:~ $ sudo install-wifi  

*** Raspberry Pi wifi driver installer by MrEngman.
*** Performing self-update
*** Relaunching after update

*** Raspberry Pi wifi driver installer by MrEngman.

Your current kernel revision = 5.4.79+
Your current kernel build    = #1373

Checking for a wifi module to determine the driver to install.

Your wifi module is Bus 001 Device 004: ID 0bda:f179 Realtek Semiconductor Corp.  

And it uses the 8188fu driver.


Your Pi revision number is 000d
You have a Pi B v2.0
Checking for a 8188fu wifi driver module for your current kernel.
There is a driver module available for this kernel revision.
Downloading the 8188fu driver, 8188fu-5.4.79-1373.tar.gz.
Installing the 8188fu driver.

Installing driver config file rtl8188fu.conf.
mv rtl8188fu.conf /etc/modprobe.d/.
Installing driver module rtl8188fu.ko.
install -p -m 644 rtl8188fu.ko /lib/modules/5.4.79+/kernel/drivers/net/wireless
Loading and running the 8188fu driver, rtl8188fu.ko.
pi@raspberrypi:~ $

Now to reboot:

Wifi rc-car is up and running,  I am able to connect via Termius, but the MQTT-Dash doesn't seem to work. 

As the HostApd is required for my ZD1211 chipset, I am not willing to change it's parameters. 





Tuesday 1 December 2020

Debugging MQTT

I have the Raspberry Pi working with Communications from MQTT-Dash on my tablet. Now I am trying to understand it better in order to get my Wemos D1 application communicating with the R-Pi. 

The Raspberry Pi has my software which is a 'subscriber' and the 'broker' is Mosquitto' on the Pi, and I  also have Paco-MQTT on the R-Pi. MQTT-Dash is the 'publisher'.

I am using this on the R-Pi to observe the traffic received my Mosquitto:

mosquitto_sub -h 192.168.4.1 -v -t "rc-car-pwm/#"   



Subscriber configuration:
broker_address= "192.168.4.1"
port = 1883
user = "rc-car-11"
password = "carr0t"
# Create client --?? Is this the same as User?
client = mqtt.Client(client_id="rc-car-11")
# Connect to broker
client.connect(broker_address,1883,60)
# Subscriber to topic
client.subscribe("rc-car-pwm")
------------------------------------
Broker Configuration:
Can't find any except default.

------------------------------------
Publisher Configuration: (MQTT-Dash)
Name: rc-car-pwm
username = rc-car-11  + Password
Client ID: rc-car-11c
and each button press sends one of the following: forward, slow, stop,motorleft, motorright, backwards
and the message payload that the subscriber gets is b'forward' etc.
-------------------------------------
whereas the monitor  command above sees:
forward,slow, etc. 
-------------------------------------

The Wemos configuration is at current:

const char* ssid = "rc-car";                     // Wifi SSID
const char* pswd = "Ashmeads";            // WiFi Password
const char* mqtt_server = "192.168.4.1";
const char* topic = "rc-car-11";    // this is the [root topic]
and this last I think has to change to 'rc-car-pwm'  because I had to put rc-car-11 into the monitor command above to see anything. 
----------------------------------------

Next step is to modify the Wemos software to send one of the words to the R-Pi and see what I get. 



The lines with just 'forward' or 'stop' or 'motorleft' are from MQTT-Dash,
the others are from the Wemos App.  When I remove that stuff in the Wemos app, it gives errors on compile. 

The line in the Wemos app that works is 
    client.publish( (char*) pubTopic.c_str() , (char*) payload.c_str(), true );
where pubTopic = topic  , which transmits 'rc-car-pwm' and the payload is 'forward' 

Sorted, now just a simple bit of programming to push the buttons and set the desired payload. And reduce the delay.


------------------------------------
And, back to 
https://madsmaddad.blogspot.com/2020/10/arduino-uno-wemos-d1-mini-wifi-and-mqtt.html


16-1-2021 
https://inventwithpython.com/blog/2012/04/06/stop-using-print-for-debugging-a-5-minute-quickstart-guide-to-pythons-logging-module/

adding debug statements to try and find out what is happening, but I can't find the logfile it is supposed to create.

3/2/2021  I found two Python test  programs on-line, and copied in my program, and both found the same error.

https://extendsclass.com/python.html           and
https://www.onlinegdb.com/online_python_debugger

But the program still didn't run.
There was more than one error. Now running

Help in using Logging: 
https://raspberrypi.stackexchange.com/questions/79421/logging-data-when-using-crontab

setting to use time, and to send data in the log message:

#logging.basicConfig(filename='temp.log', level=logging.INFO, 
      #format='%(asctime)s: %(message)s')
logging.info('temp: ' + str(temp) + '  |||  hum: ' + str(hum))