Skip to content

Instantly share code, notes, and snippets.

@iani
Created December 10, 2018 17:16
Show Gist options
  • Select an option

  • Save iani/1e3325d5f6ed6ac501ddcddd92719c9b to your computer and use it in GitHub Desktop.

Select an option

Save iani/1e3325d5f6ed6ac501ddcddd92719c9b to your computer and use it in GitHub Desktop.
Troubleshoot access to RPI-based wifi from ESP8266
print("importing time")
import time
print("done. importing osc components")
for x in range(0, 11):
print('counting up to 10:')
print(x)
time.sleep(1.0) # Delay for 1 second.
print("done importing network")
import network
print("done. populating network client variables.")
sta_if = network.WLAN(network.STA_IF)
ap_if = network.WLAN(network.AP_IF)
time.sleep(1.0)
ap_if.active(False)
time.sleep(1.0)
print("Activating standalone wifi mode now...")
sta_if.active(True)
print("DONE. Next trying to connect:")
print("================================================================")
time.sleep(1.0)
print("CONNECTING NOW")
# # sta_if.connect('ZANNOS', 'Zannos1234')
# # sta_if.connect('magnetic', 'magnetic1')
sta_if.connect('MD', 'magneticdance')
time.sleep(1.0)
print("testing if wifi is connected to magnetic network.")
print(sta_if.isconnected())
print("================================================================")
print("If the above said True then we are ok. Else we cannot send.")
print("Next importing micro-osc")
from uosc.client import Bundle, Client, create_message
print('OSC imported OK, setting client IP to: ')
# This must be checked each time. if the receiver has different address,
# the message gets lost.
clientIP = '192.168.0.110' # '10.0.1.3'
print(clientIP)
osc = Client(clientIP, 57120)
time.sleep(1.0)
# print('initializing LSM9DS0')
# import board
# import busio
# import adafruit_lsm9ds0
# i2c = busio.I2C(board.SCL, board.SDA)
# sensor = adafruit_lsm9ds0.LSM9DS0_I2C(i2c)
# print('LSM9DS0 initialized. Send loop starts in 1 second')
# print('loop period is 0.01 sec')
# time.sleep(1.0)
print('starting osc send test loop in 1 second')
time.sleep(1.0)
while True:
print("sending to osc at address:")
print(clientIP)
osc.send('/controls/frobnicator', 42, 3.1419, "spamm")
time.sleep(1.0)
# # print("will send accelerometer next:")
# # time.sleep(1.0)
# osc.send('/acceleration', *sensor.accelerometer)
# osc.send('/magnetometer', *sensor.magnetometer)
# osc.send('/gyroscope', *sensor.gyroscope)
# osc.send('/temperature', sensor.temperature)
# time.sleep(0.01)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment