element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi Projects
  • Products
  • Raspberry Pi
  • Raspberry Pi Projects
  • More
  • Cancel
Raspberry Pi Projects
Blog Syslog: Sending Log Messages to a Server with MicroPython
  • Blog
  • Documents
  • Events
  • Polls
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi Projects to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: shabaz
  • Date Created: 25 Jan 2026 4:59 PM Date Created
  • Views 153 views
  • Likes 11 likes
  • Comments 10 comments
  • Pi Pico W
  • rpiintermediate
  • syslog
  • micropython
  • api
  • pico w
  • pi pico
Related
Recommended

Syslog: Sending Log Messages to a Server with MicroPython

shabaz
shabaz
25 Jan 2026

Introduction

Installing MicroPython on your microcontroller board allows you to write and immediately run Python code, without needing to build or compile the code. It’s a really fast way of creating applications.

Usually I use print statements to see what’s going on in the code, but I might not always have a PC connected, nor an LCD screen. It was time to find an alternative solution!

This very short blog post discusses how to edit and run Python code (well, MicroPython code, but it’s almost the same thing) on a Pi Pico W using an editor tool called Thonny, and how to view log content remotely using an application called a syslog server. It is very lightweight, it uses UDP messages over the network.

General Overview

The Python code will first import some general network functions:

from net_utils import NET_UTILS

Next, in the main function, a net_utils object is created:

net_utils = NET_UTILS()

You can connect to the WiFi by the following command:

net_utils.wifi_connect()

The WiFi SSID and password from a file called secrets.py will be used.

To send messages to a syslog server running on a PC, the following commands are used:

net_utils.syslog_init()
net_utils.syslog("hello this is a message!”)

That’s it, it’s very simple.

Getting Started

I purchased a Pi Pico-W, and then downloaded the MicroPython UF2 file from the raspberrypi MicroPython page.

The UF2 file is effectively the binary for the MicroPython operating system. I held down the Boot button on the Pi Pico-W, and then plugged in the USB cable, and then drag-and-dropped that UF2 file onto the drive letter that appeared.

Here is a video showing how to do that:

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

Obtain Example Code

I created some example code downloadable from GitHub. It can be downloaded as a zip file, by clicking on the green button and selecting Download ZIP. When extracted, there will be three files: main.py, net_utils.py, and secrets_example.py.

The secrets_example.py file needs to be renamed to secrets.py, and then edited to insert your WiFi SSID and password. (Note: the SSID and password are stored in plain text and very easy to extract, so you wouldn't do this generally; it's best to have a dedicated SSID and network for your experiments, so that there's no harm if the credentials are leaked).

The example code connects the Pico W to the network using WiFi, repeatedly retrieves the current temperature, and sends it in a message to the syslog server every minute.

Quick Thonny Guide

Thonny is a simple text editor and tool for uploading Python files. I downloaded and installed Thonny from the Thonny website: 

The screenshot below shows how to use Thonny. Click the red circle to connect to the Pi Pico-W.

image

The blue area is used to select the current folder (select the folder where the example code extracted zip file contents were placed).

Once that’s done, the files in that folder will be listed below (orange box). Now you can select one or more files, and then right-click, and see the purple menu appear. From there, if you select Upload to / then the selected files will be transferred via USB to the Pi Pico-W. You’ll know when that is done, because they will be listed at the bottom-left (black box).

The main.py code will automatically run if the Pico-W is power-cycled, but you don’t need to do that. Instead, just double-click on the main.py file in the orange box, so that the contents appear in the main editor pane. Next, click the green circled icon, and the code will immediately run. You’ll see any print statements appear in the pane just below the editor pane (the pane is labelled Shell).

To stop the code, click in the pane below the editor pane, and press Ctrl-C. You;ll see a Python prompt.

If you wish to make code changes, do that in the editor pane, then save the file, then redo the steps to Upload to / and then to rerun the code, press the green circled icon again.

Running the Example Code

When you run the code as explained in the Quick Thonny Guide, you should see the following in Thonny's Shell pane; it will display the IP address that your Pi Pico-W has acquired, and the temperature at the latitude and longitude for Alcatraz (it’s just a demo location).

image

Installing and Configure a Syslog Server

The Syslog Server is the software application that will collect and display the logs. I used an application called Kiwi Syslog Server Free Edition.

During installation, I chose to run it as an application rather than a service. Run the application, and select File->Setup, and then in the window that appears, select Inputs on the left, and then enter the IP address of the Pico-W in the red highlighted area, and click Add, then Apply, then OK. Now the Syslog server is ready to accept log messages from the Pico-W.

image

Configure the Pico-W to send Syslog Messages

Find out the IP address of your PC, and then go to the secrets.py file using Thonny, and edit the SYSLOG_SERVER IP address to be the PC’s IP address.

Re-run the code (i.e. stop the code first by Ctrl-C in the shell pane, then select main.py and then press the green circled icon as indicated earlier.

You should see logs appear!

image

Obtaining the Temperature

If you're curious, the main.py code shows how the temperature was obtained from a web API accessible from open-meteo. If you look at that site, you can see it describes a URL of https://api.open-meteo.com/v1/forecast with longitude and latitude parameters, and you can see the returned message format, it's known as JSON:

image

I used that URL and used this command to send the request:

data = net_utils.get_json_with_retries(url)
The temperature was pulled from the returned data, which is in JSON format and easily extracted:
cur = data.get("current")
temp = cur.get("temperature_2m")

Summary

MicroPython makes it very easy to quickly prototype things on a microcontroller.

A very lightweight remote logging method can be easily implemented in MicroPython. Syslog is a very well-known protocol. Simple code was presented that will send messages to a free syslog server. An API demo was presented using open-meteo.

Thanks for reading!

  • Sign in to reply
  • shabaz
    shabaz 12 hours ago in reply to BigG

    The very basic SNMPv1 is tiny both over the network and at the SNMP agent (end device) code side, a UDP payload of about 55 bytes. It's verbose at the PC end for configuration, but that's manageable (I'm cheating, been getting AI to write that since it's tedious and error-prone to do it without any tools).

     I've been looking for basic monitoring tools, a very lightweight one is called iReasoning. Here's what it looks like.

    The free version cannot plot charts : ( Anyway, it seems sufficient for now while still working on the code. And then it will be straightforward to use Python code to plot the desired attribute(s) over time.

    image

    image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • BigG
    BigG 1 day ago in reply to shabaz

    Ah yes SNMP. A rather verbose protocol, if memory serves me correctly. I can now see why you chose the Pico as it would really shine here and, fair enough, in this type of application I too would probably avoid punishing myself with string parsing/searches/manipulation in C, when Python has the means for you. KISS applies, for sure.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • shabaz
    shabaz 1 day ago in reply to balajivan1995

    I like Wireshark too. The syslog implememention I'm using is very cut-down, so the overhead is almost as little as the bare message payload, with just a few bytes added:

    image

    This is what it comes out as (this is from my heating controller project [  FSK Demodulation with R&S FPC Spectrum Analyzers, or How I Achieved an Optimal Room Temperature  ], I've now added the syslog capability to it); it's a heartbeat message sent every hour, to see if the controller has died or not:

    image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • balajivan1995
    balajivan1995 2 days ago

    I have once used plain UDP multicast to send data from one esp32 to another. If the temperature doesn't change drastically, you can use plain UDP to send message and receive it using Wireshark. It won't take much time to transmit a message, payload is much smaller.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • embeddedguy
    embeddedguy 2 days ago

    Nice first line, I fell the same. about Micropython.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2026 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube