-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
peripheral.py returns errors when commanding #2
Comments
Hi @aofek, After seeing your error, it seems that you typed 'advertise' instead of advertise (without the quotation marks). The quotation marks in the script are to indicate that it is a string. However, when you enter the command in the console, it should be without quotation marks. Can you attempt this fix and check whether this solves the problem? EDIT: Hmm the error on your second screenshot seems weird. I suspect the function signature has changed since I made this script. Some suggestions that I have:
Unfortunately, I currently do not possess any devices equipped with MicroPython anymore to reproduce and debug your errors. Hopefully, my pointers above are helpful enough to guide you in the correct direction for the solution. |
Hi James |
Dear James
using esp32 with your "peripheral.py" returns a message as in the pictures, while the "basic_ble.py" activates the advertising, connects and communicates with "serial bluetooth terminal" app on the phone.
I am searching for "notify a close-by ble device" which means using the esp32 periodically on scan/advertise mode without connection , preferably with rssi signal level upon detection.
could you help me , please, understand what is the nature of the error, so I can switch between the 2 modes with time sharing?
``
the esp32 dev board is a basic board, nothing fancy, "Lolin
D32"
---code---- basic_ble.py
boot section
import esp
import esp32
import micropython
from micropython import const
import machine
from machine import Pin,I2C,SoftI2C,ADC,Timer
import utime
import time
from time import sleep_ms
import struct
import random
import network
import ubluetooth
from ubluetooth import BLE
adcamp1=ADC(Pin(32))
adcamp2=ADC(Pin(33))
adcamp3=ADC(Pin(34))
adcbat=ADC(Pin(35))
led=Pin(2,Pin.OUT) # pin 2 in devkit1
machine.freq(240000000)
#------------------------------------------
class BLE(): # BLE class
def init(self, name):
self.name = name
self.ble = ubluetooth.BLE()
self.ble.active(True)
#----------------------------------------
def adc_loop():
amp1 =adcamp1.read()
amp1=amp1+1000
amp2 =adcamp2.read()
amp2=amp2+1000
amp3 =adcamp3.read()
amp3=amp3+1000
bat =adcbat.read()
bat=bat+1000
magdat=[amp1]+[amp2]+[amp3]+[bat]
print(magdat)
return magdat
#--------------------------------------------------------
if name == 'main':
ble = BLE('hmc001')
The text was updated successfully, but these errors were encountered: